I'm following this blog to implement autocomplete feature. I tried creating the exact mapping but stumbled upon some error.
Following is my intended mapping query.
curl -XPUT "http://localhost:9200/blurays " -d'
{
"settings": {
"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": {
"movies": {
"_all": {
"index_analyzer": "nGram_analyzer",
"search_analyzer": "whitespace_analyzer"
},
"properties": {
"addToCartUrl": {
"type": "string",
"index": "no",
"include_in_all": false
},
"format": {
"type": "string",
"index": "not_analyzed"
},
"mpaaRating": {
"type": "string",
"index": "not_analyzed",
"include_in_all": false
},
"price": {
"type": "double",
"include_in_all": false
}
}
}
}
}'
Following is the error that I'm getting:-
analyzer on field [_all] must be set when search_analyzer is set
I'm using the latest version of the ES, ie 2.3 and this was written 2 years back. I've just started learning ES. What can be the possible solution to this?
When defining the _all
field you need to replace index_analyzer
with analyzer
as this has been renamed in 2.0.
"_all": {
"analyzer": "nGram_analyzer",
"search_analyzer": "whitespace_analyzer"
},
Agreed, the error message could be better, though.