Elasticsearch Index API
์ธ๋ฑ์ค๋ฅผ ์์ฑ
, ์ญ์
, ์กด์ฌ์ฌ๋ถ
, status
(open/close) ์ฌ๋ถ, shrink
(์ค๋ ์ถ์), split
(์ค๋ ํ์ฅ), refresh
(๋ฃจ์ฌ์ flush๋ก ์ด ์์
์ด ์ํ๋์ด์ผ ์ธ๊ทธ๋จผํธ ํ์ผ์ด ์์ฑ๋ผ ์๋ก์ด doc์ด ๊ฒ์์ด ๊ฐ๋ฅํด์ง๋ค. ์ปค๋์์ ์์คํ
์บ์์ ํ์ผ๋ง ์์ฑ/์ฃผ๊ธฐ์ ์ผ๋ก ์๋ ํธ์ถ ๋๋ค.), flush
(๋ฃจ์ฌ์ commit์ผ๋ก dixc์ ์์์ฑ์ผ๋ก ์ ์ฅ์ธ๋๋ ๋จ๊ณ) , forcemerrge
(๋ฃจ์ฌ์ merge๋ก ์ฌ๋ฌ๊ฐ์ ์ธ๊ทธ๋จผํธ๋ฅผ ํฉ์น๋ ์์
์ผ๋ก memory,disk๋ฑ์ ์ ์ฝํ๊ณ ์ธ๋ฑ์ฑ์ ์๋ก ์ต์ ํํ์ฌ ์ํ), rollover
(active index๊ฐ ์ค๋๋ฌ๊ฑฐ๋ ํฌ๊ธฐ๊ฐ ์ปค๋ฒผ ๋น ์ธ๋ฑ์ค๋ฅผ ๋ง๋ค๊ณ ๊ต์ฒด๊ฐ ํ์ํ ๋ ์ฌ์ฉ)
GetIndex
client์ index์ ์ ๋ณด๋ฅผ client.indices().get()์ ํตํด ์กฐํํ ์ ์์ผ๋ฉฐ ์ด๋ ์ฒซ๋ฒ์งธ ์ธ์๋ก GetIndexRequest()๋ฅผ ํตํด ํน์ index๋ฅผ ๋ฆฌ์ ํ ์ ์๊ณ *
์ ์ฃผ์ด์ง๋ฉด ๋ชจ๋ index๋ฅผ ์กฐํํ๋ค. (/_cat/indices ์ ๋์ผ)
GetIndexResponse
๋ด๋ถ ํ๋๋ก mappings
,aliases
,settings
,defaultSettings
,dataStreams
,indices
๊ฐ ์กด์ฌํ๊ณ getter๋ฅผ ํตํด ์กฐํ๊ฐ ๊ฐ๋ฅํ๋ค.
1. settings
index๋ค์ id, ์์ฑ์ผ์, analyzer๋ฑ๊ณผ ๊ฐ์ ์ธํ ์ ๋ณด๊ฐ Map์ ํํ๋ก ํฌํจ๋๊ธฐ ๋๋ฌธ์ getSettings()์์ get()์ ์ด์ค์ผ๋ก ์ฌ์ฉํ์ฌ ๊ฐ์ ์กฐํํ๊ฑฐ๋ getSetting()๋ฉ์๋๋ฅผ ์ด์ฉํด์ ์ธํ ์ ๋ณด๋ฅผ ์กฐํํ ์ ์๋ค.
2. indices
์กฐํํ index๋ค์ ์ด๋ฆ๋ค์ String[]ํํ๋ก ํฌํจํ๊ณ ์๋ ํ๋
3. aliases
response.getAliases()
index์ ๋ณ์นญ๋ค์ ์ ๋ณด๋ฅผ ์ ์ฅํ๊ณ ์๋ ํ๋๋ก /_cat/aliases
๋ฅผ ์ด์ฉํ์ฌ ์กฐํํ๊ฒ๊ณผ ๋น์ทํ๋ค. ์ด๋ Mapํํ๋ก ์ ์ฅ์ ํ๊ณ ์์ผ๋ฉฐ key๋ก๋ index๋ช
, value๋ก๋ aliases์ ๋ฉํ์ ๋ณดํ๋ list ๊ฐ ๋ค์ด์๋ค.
+) /_cat/indices
์์ ๋ช
๋ น์ด๋ ?v
๋ฅผ ์ถ๊ฐํด column์ ํฌํจํด ์ ๋ณด๋ฅผ ์กฐํํ๊ณ ์ถ๋ค๋ฉด lowClient๋ฅผ ์ด์ฉํด ์กฐํํ ์๋ ์๋ค.
์๋ต์ด ๋ฌธ์์ด๋ก ์์ ๊ฐ์ด ์ค๊ธฐ ๋๋ฌธ์ jsonํํ์ ๋ต์ ์ํ๋ฉด ๋ณ๋๋ก ํ์ฑ์ ํ์ฌ ์ฌ์ฉํ๊ฑฐ๋ EntityUtils์ด ์๋ getContent()๋ฉ์๋๋ฅผ ์ด์ฉํด์ InputStream์ผ๋ก ํ ์ค ์ฉ ์ฝ์ด ํ์ฑํด์ ์ฌ์ฉ๊ฐ๋ฅํ๋ค.
Last updated