elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.52k stars 24.9k forks source link

No validation of custom analyzer when updating index setting on a closed index #9879

Closed colings86 closed 6 years ago

colings86 commented 9 years ago

Steps to reproduce:

DELETE test_idx

# create an index
PUT test_idx
{
    "settings" : {
        "number_of_shards" : 3,
        "number_of_replicas" : 2
    }
}

# Close the index to we can change non-dynamic settings
POST test_idx/_close

# Add custom analyzer that points to a non-existant tokenizer
PUT test_idx/_settings
{
        "analysis": {
            "analyzer": {
                "my_custom_analyzer_1": {
                    "tokenizer": "my_custom_tokenizer"
                }
            }
        }
}

# Open the index (no error)
POST test_idx/_open

# Get the index settings (analyzer has been added)
GET test_idx/_settings

# Try to use the analyzer in a mapping (validation error here)
PUT test_idx/_mapping/type
{
  "doc": {
    "properties": {
      "field": {
        "type": "string",
        "analyzer": "my_custom_analyzer_1"
      }
    }
  }
}

We should validate the analyzer when the settings are updated so we don't have invalid analyzers defined in the index settings. Interestingly we actually do validate the analyzer if you try to add it when creating the index.

PUT test_idx
{
    "settings" : {
        "number_of_shards" : 3,
        "number_of_replicas" : 2,
        "analysis": {
            "analyzer": {
                "my_custom_analyzer_1": {
                    "tokenizer": "my_custom_tokenizer"
                }
            }
        }
    }
}

Errors with:

{
   "error": "IndexCreationException[[test_idx] failed to create index]; nested: IllegalArgumentException[Custom Analyzer [my_custom_analyzer_1] failed to find tokenizer under name [my_custom_tokenizer]]; ",
   "status": 400
}

This issue was raised in a mailing list post: https://groups.google.com/forum/#!topic/elasticsearch/roLINFQWfFc

sriram2520 commented 7 years ago

Encountered an exact issue today on version 5.2.2. Created a custom analyzer, but the tokenizer name was spelled incorrectly. Now I can't open the index. And seems like I can't delete the custom analyzer also.

Keep getting this error, when I try to update the settings.

Custom Analyzer [custom_minhash_analyzer] failed to find tokenizer under name [min_hash]

asuiu commented 7 years ago

Any workarounds? I can't create another index at all after getting this error. Is there any way to hard-reset ES ?

alexshadow007 commented 7 years ago

@colings86 I think this issue was fixed by #24487

rjernst commented 6 years ago

I agree this should be fixed by #24487. Closing.