Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a list of closed indexes in ElasticSearch?

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

I want to re-open it, but god forbid I forget which index I closed.

How do get a list of all the 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.

like image 729
grayaii Avatar asked Feb 20 '14 19:02

grayaii


People also ask

What are closed indices in Elasticsearch?

A closed index is blocked for read/write operations and does not allow all operations that opened indices allow. It is not possible to index documents or to search for documents in a closed index.

How do you open a closed index?

All indices can be opened or closed at once using _all as the index name or specifying patterns that identify them all (e.g. * ). Identifying indices via wildcards or _all can be disabled by setting the action. destructive_requires_name flag in the config file to true .

Where are indexes stored in Elasticsearch?

Indexes are stored on disk as configured in elasticsearch. yml with the configuration option path. data ; localhost on port 9200 is the default connection port for the HTTP REST interface, the path of the url generally defines an action to be taken (like searching for documents);


1 Answers

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

Get the answer from IndicesOptions.java from 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()
    );
}
like image 183
Scott Ding Avatar answered Jan 01 '23 08:01

Scott Ding