Currently (v. 1.4.2) it is possible to check the existence of an index (although maybe not the ideally way), and to close and open an index. I don't see a way of checking if the index is opened or closed.
The status call returns an "IndexClosedException" which falls more in an exception handling case instead of informational one that I'm looking for.
How do you check this? Or is there another way to make a search without (possibly) passing an already closed index?
Use GET /_cat/indices/my_index?v
and you get something like this back:
health status index pri rep docs.count docs.deleted store.size pri.store.size
yellow open my_index 5 1 2 0 5.3kb 5.3kb
And you can see the status
column.
While the _cat endpoint is nice for humans, if you want something more script/program friendly you can do something like...
Lookup for a single index:
curl -GET 'http://es-host:9200/_cluster/state' | jq '.metadata.indices["index_name"].state'
List all indices:
curl -GET 'http://es-host:9200/_cluster/state' | jq '.metadata.indices | to_entries | .[] | {index: .key, state: .value.state}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With