'Elasticsearch index with yellow health

I'm working on a large CPython codebase that uses Elasticsearch.

Normally, this codebase creates n indexes and n aliases, and there's a one-to-one correspondence between these indexes and aliases.

But once in a while, I instead get n indexes and n-1 aliases, and one of the indexes has a name that should've been used by an alias.

For some reason when this happens, the bogus index-that-has-what-should-be-an-alias-name has yellow status, while the other indexes are all green.

What might cause an index to be the only one that is yellow? I'm hoping understanding this might help me narrow down which part of the code I need to scrutinize to fix the bug


Edit: My elasticsearch.yml has just:

cluster.name: "docker-cluster"
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["127.0.0.1", "[::1]"]

In production we may have more ES nodes, but this is just a test system - so just one ES node.



Solution 1:[1]

Elasticsearch will never assign a replica to the same node as the primary shard, so if you only have one node it is perfectly normal and expected for your cluster to indicate yellow. If you feel better about it being green, then change the number of replicas on each index to be 0.

PUT /my-index/_settings
{
    "index" : {
        "number_of_replicas" : 0
    }
}

Please read this blog https://opster.com/guides/elasticsearch/operations/elasticsearch-yellow-status/

It explains very well how to fix yellow indexes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1