- 
                Notifications
    You must be signed in to change notification settings 
- Fork 25.6k
Closed
Labels
:Search Relevance/AnalysisHow text is split into tokensHow text is split into tokens:SearchOrg/RelevanceLabel for the Search (solution/org) Relevance teamLabel for the Search (solution/org) Relevance team>bugTeam:Search RelevanceMeta label for the Search Relevance team in ElasticsearchMeta label for the Search Relevance team in Elasticsearchpriority:highA label for assessing bug priority to be used by ES engineersA label for assessing bug priority to be used by ES engineers
Description
Elasticsearch Version
8.10+
Installed Plugins
No response
Java Version
bundled
OS Version
any
Problem Description
It is possible to create an index with an analyzer that uses a synonym or synonym_graph filter, that point to a synonym set that does not exist.
When that happens, the index is created but the shards cannot be recovered (as synonyms are loaded during shard recovery). This makes both the index and the cluster health to be red, as no shard can be recovered for it.
Users can solve the problem by creating the synonym set via the Synonyms API.
Steps to Reproduce
Create an index that uses a synonyms set that has not been created yet:
PUT test-synonyms
{
  "settings": {
    "analysis": {
      "filter": {
        "synonyms_filter": {
          "type": "synonym_graph",
          "synonyms_set": "my-synonyms-set",
          "updateable": true
        }
      },
      "analyzer": {
        "my_index_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": ["lowercase"]
        },
        "my_search_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": ["lowercase", "synonyms_filter"]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "analyzer": "my_index_analyzer",
        "search_analyzer": "my_search_analyzer"
      }
    }
  }
}The index is created, but shards do not acknowledge:
{
    "acknowledged": true,
    "shards_acknowledged": false,
    "index": "test-synonyms"
}The index and the cluster are in red status:
GET _cat/indices
    {
        "health": "red",
        "status": "open",
        "index": "test-synonyms",
        "uuid": "CFdqVx5XRsCvIpNGLEQHbw",
        "pri": "1",
        "rep": "1",
        "docs.count": null,
        "docs.deleted": null,
        "store.size": null,
        "pri.store.size": null,
        "dataset.size": null
    }Logs (if relevant)
No response
Metadata
Metadata
Assignees
Labels
:Search Relevance/AnalysisHow text is split into tokensHow text is split into tokens:SearchOrg/RelevanceLabel for the Search (solution/org) Relevance teamLabel for the Search (solution/org) Relevance team>bugTeam:Search RelevanceMeta label for the Search Relevance team in ElasticsearchMeta label for the Search Relevance team in Elasticsearchpriority:highA label for assessing bug priority to be used by ES engineersA label for assessing bug priority to be used by ES engineers