How to get a list of private indexes in ElasticSearch?

I recently closed the index through the Head plugin in Elasticsearch. I did NOT delete it.

I want to open it again, but God forbid, I forgot which index I closed.

How to get a list of all indexes that I closed?

I tried:

curl -s localhost:9200/_stats | grep logstash-2013.12.05 curl -s localhost:9200/_status | grep logstash-2013.12.05 

But no luck.

+7
elasticsearch
source share
8 answers

On request: / _cluster / state / metadata

You get a list of indexes, from each index you can request a state: metadata.indices ["your_index"]. state

I also use this in my plugin, and it works for me: http://www.gridshore.nl/esgui/

+6
source share

You can use this:

 http://yourserver:9200/_cluster/state/blocks?pretty 

it would be nice if Elasticsearch sticks to it on this page: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html

+7
source share

There is still no API for this. But you can write a script to determine which index is closed.

API check:

  curl -XGET http://localhost:9200/_cluster/health/logstash-2014.02.21?pretty 

Here is the status of the index

Zip open:

 { "cluster_name" : "ABC", "status" : "green", "timed_out" : false, "number_of_nodes" : 1, "number_of_data_nodes" : 1, "active_primary_shards" : 1, "active_shards" : 1, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0 } 

Index closed:

 { "cluster_name" : "ABC", "status" : "green", "timed_out" : false, "number_of_nodes" : 1, "number_of_data_nodes" : 1, "active_primary_shards" : 0, "active_shards" : 0, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0 } 

From the information you can determine the status of the active_primary_shards index. Hope this helps you.

+4
source share

Since Elasticsearch 5 you can sort the catalog output

 GET /_cat/indices?v&s=status:asc 

Would give you enter image description here

+2
source share

If the only question for you here is simply to see which index is closed, i.e. administrative task that you can use, for example. ElasticSearh Head Plugin:

 http://yourserver:9200/_plugin/head/ 

Do not forget the last slash. If you cannot install it (for example, on some hosted ElasticSearch) or cannot use it for another reason or want to manipulate indexes programmatically, you can use other tips here to find out using the API.

PS: / _ cluster / state / metadata can really be very very long, for example. if you use dynamic matching.

+1
source share

Use Curl GET _cat / index, $ 2 will show the status of your index.

+1
source share

Adding a command that prints a list of private indexes (and nothing more) for which I searched for search queries.

 curl -s -XGET 'http://localhost:9200/_cat/indices?h=status,index' | awk '$1 == "close" {print $2}' 
  • -s will disable the curl, so it does not display the status bar
  • h=status,index The parameter tells the _cat to print only two columns
  • awk filter will print index names when status is close.

See also: https://www.elastic.co/guide/en/elasticsearch/reference/2.4/cat-indices.html


The newer version of the _cat command _cat more powerful. Sorting, filtering, you name it. See: https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html

+1
source share
 http://es_endpoints.com:9200/index-pattern-*/_settings?expand_wildcards=closed 

Get the answer from IndicesOptions.java from the ES source code:

 public static IndicesOptions fromParameters(Object wildcardsString, Object ignoreUnavailableString, Object allowNoIndicesString, IndicesOptions defaultSettings) { if (wildcardsString == null && ignoreUnavailableString == null && allowNoIndicesString == null) { return defaultSettings; } boolean expandWildcardsOpen = false; boolean expandWildcardsClosed = false; if (wildcardsString == null) { expandWildcardsOpen = defaultSettings.expandWildcardsOpen(); expandWildcardsClosed = defaultSettings.expandWildcardsClosed(); } else { String[] wildcards = nodeStringArrayValue(wildcardsString); for (String wildcard : wildcards) { if ("open".equals(wildcard)) { expandWildcardsOpen = true; } else if ("closed".equals(wildcard)) { expandWildcardsClosed = true; } else if ("none".equals(wildcard)) { expandWildcardsOpen = false; expandWildcardsClosed = false; } else if ("all".equals(wildcard)) { expandWildcardsOpen = true; expandWildcardsClosed = true; } else { throw new IllegalArgumentException("No valid expand wildcard value [" + wildcard + "]"); } } } //note that allowAliasesToMultipleIndices is not exposed, always true (only for internal use) return fromOptions( nodeBooleanValue(ignoreUnavailableString, "ignore_unavailable", defaultSettings.ignoreUnavailable()), nodeBooleanValue(allowNoIndicesString, "allow_no_indices", defaultSettings.allowNoIndices()), expandWildcardsOpen, expandWildcardsClosed, defaultSettings.allowAliasesToMultipleIndices(), defaultSettings.forbidClosedIndices(), defaultSettings.ignoreAliases() ); } 
0
source share

All Articles