【ElasticSearch問題1】建立索引的時候報mapper_parsing_exception
阿新 • • 發佈:2018-09-03
sha min ppi error 參數 建立索引 code ror exceptio 報錯日誌:
網上寫elasticsearch也有很多文章,都寫的挺好的,目前想把錯誤日誌以及解決方法寫出來,希望一些小夥伴能盡快躲開些問題,把時間花在一些有用的事情上。
網上寫elasticsearch也有很多文章,都寫的挺好的,目前想把錯誤日誌以及解決方法寫出來,希望一些小夥伴能盡快躲開些問題,把時間花在一些有用的事情上。
錯誤日誌 { "error": { "root_cause": [ { "type": "mapper_parsing_exception", "reason": "analyzer on field [word] must be set when search_analyzer is set" } ], "type": "mapper_parsing_exception", "reason": "Failed to parse mapping [doc]: analyzer on field [word] must be set when search_analyzer is set", "caused_by": { "type": "mapper_parsing_exception", "reason": "analyzer on field [word] must be set when search_analyzer is set" } }, "status": 400 }
建立索引的條件:
{ "settings": { "number_of_shards": 1, "analysis": { "filter": { "ngram_filter": { "type": "ngram", "min_gram": 2, "max_gram": 20 } }, "analyzer": { "ngram_analyzer": { "type": "custom", "tokenizer": "standard", "filter": [ "lowercase", "ngram_filter" ] } } } }, "mappings": { "doc": { "_all": { "type": "text", ** "index_analyzer": "ngram_analyzer",** "search_analyzer": "standard" }, "properties": { "word": { "type": "text", ** "index_analyzer": "ngram_analyzer",** "search_analyzer": "standard" }, "definition": { "type": "text" } } } } }
為什麽呢?因為mappings裏有寫參數在elasticsearch5版本裏不支持了,index_analyzer就不支持了,改成了analyzer,改過來,就好了,可以建立索引成功。
【ElasticSearch問題1】建立索引的時候報mapper_parsing_exception