mapper_parsing_exception in new elasticsearch 2.1.1 version
Asked Answered
N

1

6

Problem : I have created mapping and its working fine in elasticsearch 1.7.1 but after updating to 2.1.1 it will give me exception

EXCEPTION

  response: '{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason"
:"analyzer on field [_all] must be set when search_analyzer is set"}],"type":"ma
pper_parsing_exception","reason":"Failed to parse mapping [movie]: analyzer on f
ield [_all] must be set when search_analyzer is set","caused_by":{"type":"mapper
_parsing_exception","reason":"analyzer on field [_all] must be set when search_a
nalyzer is set"}},"status":400}',
  toString: [Function],
  toJSON: [Function] }

{
    "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0,
        "analysis": {
            "filter": {
                "nGram_filter": {
                    "type": "nGram",
                    "min_gram": 2,
                    "max_gram": 20,
                    "token_chars": [
                        "letter",
                        "digit",
                        "punctuation",
                        "symbol"
                    ]
                }
            },
            "analyzer": {
                "nGram_analyzer": {
                    "type": "custom",
                    "tokenizer": "whitespace",
                    "filter": [
                        "lowercase",
                        "asciifolding",
                        "nGram_filter"
                    ]
                },
                "whitespace_analyzer": {
                    "type": "custom",
                    "tokenizer": "whitespace",
                    "filter": [
                        "lowercase",
                        "asciifolding"
                    ]
                }
            }
        }
    },
    "mappings": {
        "movie": {
            "_all": {
                "index_analyzer": "nGram_analyzer",
                "search_analyzer": "whitespace_analyzer"
            },
            "properties": {
                "movieName": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "movieYear": {
                    "type": "double"
                },
                "imageUrl": {
                    "type": "string"
                },
                "genre": {
                    "type": "string"
                },
                "director": {
                    "type": "string"
                },
                "producer": {
                    "type": "string"
                },
                "cast": {
                    "type": "String"
                },
                "writer": {
                    "type": "string"
                },
                "synopsis": {
                    "type": "string"
                },
                "rating": {
                    "type": "double"
                },
                "price": {
                    "type": "double"
                },
                "format": {
                    "type": "string"
                },
                "offer": {
                    "type": "double"
                },
                "offerString": {
                    "type": "string"
                },
                "language": {
                    "type": "string"
                }
            }
        }
    }
}
Nealneala answered 3/1, 2016 at 12:52 Comment(0)
A
11

The error is quite clear if you ask me, you need to specify analyzer for _all in your movie mapping. Setting index_analyzer was removed in Elasticsearch 2.0.

        "_all": {
            "analyzer": "nGram_analyzer",
            "search_analyzer": "whitespace_analyzer"
        },
Anywise answered 3/1, 2016 at 13:7 Comment(2)
then what is index_analyzer ? can you please tell meNealneala
In Elasticsearch before 2.0 you could set index_analyzer, search_analyzer or simply analyzer. The last one was a shorthand for setting both index_analyzer and search_analyzer to the same value. In Elasticsearch 2.0 they changed it so that index_analyzer is now just analyzer and if you don't set a separate search_analyzer the value from analyzer is used for that as well.Eddieeddina

© 2022 - 2024 — McMap. All rights reserved.