{"id":1452,"date":"2015-02-24T10:20:10","date_gmt":"2015-02-24T02:20:10","guid":{"rendered":"https:\/\/cowmanchiang.me\/wp\/?p=1452"},"modified":"2023-10-31T15:43:49","modified_gmt":"2023-10-31T07:43:49","slug":"elasticsearch-list-all-indexes-and-optimize-it","status":"publish","type":"post","link":"https:\/\/cowmanchiang.me\/wp\/?p=1452","title":{"rendered":"[Elasticsearch] List all indexes and optimize it."},"content":{"rendered":"<p>When we deleted the indexes, the data were just marked by deleted.<br \/>\nWe can list all indexes to show status.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">sudo curl &#039;localhost:9200\/_cat\/indices?v&#039;<\/pre>\n<p>It will show the health, index name, pri, rep, docs.count, docs.deleted, store.size, pri.store.size.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">health index               pri rep docs.count docs.deleted store.size pri.store.size\nyellow kibana-int            5   1          5            0     66.7kb         66.7kb\nyellow logstash-2015.02.13   5   1     402030      3366353      1.2gb          1.2gb\nyellow logstash-2015.02.18   5   1      86843      3393979      1.1gb          1.1gb\nyellow logstash-2015.02.15   5   1     218402      3063776      1.2gb          1.2gb\nyellow logstash-2015.02.03   5   1     178621      2072000    756.3mb        756.3mb\nyellow logstash-2015.02.06   5   1     466185      2479658    963.4mb        963.4mb\nyellow logstash-2015.02.24   5   1     364473            0    166.5mb        166.5mb\nyellow logstash-2015.02.02   5   1     313488      1838855    710.1mb        710.1mb\nyellow logstash-2015.02.07   5   1     371602      3397300      1.2gb          1.2gb\nyellow logstash-2015.02.21   5   1    3583288            0      1.2gb          1.2gb\nyellow logstash-2015.02.22   5   1    3554707            0      1.1gb          1.1gb\nyellow logstash-2015.02.23   5   1    3680625            0      1.2gb          1.2gb<\/pre>\n<p>If we want to clear the deleted indexes, we can optimize it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">sudo curl -XPOST &#039;http:\/\/localhost:9200\/_optimize&#039;<\/pre>\n<p>And it will reply this message.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">{&quot;_shards&quot;:{&quot;total&quot;:310,&quot;successful&quot;:155,&quot;failed&quot;:0}}<\/pre>\n<p>Then when we list all indexes again, we will see the deleted indexes are gone.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">cowman@roamingcacti:~$ sudo curl &#039;localhost:9200\/_cat\/indices?v&#039;\nhealth index               pri rep docs.count docs.deleted store.size pri.store.size\nyellow kibana-int            5   1          5            0     66.5kb         66.5kb\nyellow logstash-2015.02.13   5   1     402030      1512300    611.7mb        611.7mb\nyellow logstash-2015.02.18   5   1      86843      1374178    491.9mb        491.9mb\nyellow logstash-2015.02.15   5   1     218402      1404862    536.7mb        536.7mb\nyellow logstash-2015.02.03   5   1     178621      2072000    756.2mb        756.2mb\nyellow logstash-2015.02.06   5   1     466185      2479658    963.4mb        963.4mb\nyellow logstash-2015.02.24   5   1     378777            0    156.9mb        156.9mb\nyellow logstash-2015.02.02   5   1     313488      1838855    710.1mb        710.1mb\nyellow logstash-2015.02.07   5   1     371602      1394610    566.5mb        566.5mb\nyellow logstash-2015.02.21   5   1    3583288            0      1.2gb          1.2gb\nyellow logstash-2015.02.22   5   1    3554707            0      1.1gb          1.1gb\nyellow logstash-2015.02.23   5   1    3680625            0      1.2gb          1.2gb<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When we deleted the indexes, the data were just marked by deleted. We can list all indexes to show status. sudo curl &#039;localhost:9200\/_cat\/indices?v&#039; It will show the health, index name, pri, rep, docs.count, docs.deleted, store.size, pri.store.size. health index pri rep &hellip; <a href=\"https:\/\/cowmanchiang.me\/wp\/?p=1452\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-1452","post","type-post","status-publish","format-standard","hentry","category-elasticsearch"],"_links":{"self":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1452"}],"version-history":[{"count":1,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1452\/revisions"}],"predecessor-version":[{"id":1929,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1452\/revisions\/1929"}],"wp:attachment":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}