So folks, I started my studies with elasticsearch and started trying to build an autocomplete with edge - ngram tokenizer on my machine and found a problem when trying to follow the documentation for such a configuration.
I followed the following steps:
I created my index with a standard configuration as the documentation requested:
{ "settings": { "analysis": { "analyzer": { "autocomplete": { "tokenizer": "autocomplete", "filter": [ "lowercase" ] }, "autocomplete_search": { "tokenizer": "lowercase" } }, "tokenizer": { "autocomplete": { "type": "edge_ngram", "min_gram": 2, "max_gram": 10, "token_chars": [ "letter" ] } } } } }I added an item to the index via bulk:
{"index":{"_index":"products","_type":"products"}}{"sku":"73792589","name":"Bruno's test","img":"73792589_5911_20201229172349.jpg,73792589_5911_20201229172349.jpg,73792589_5911_20201229172349.jpg,73792589_5911_20201229172349.jpg,73792589_5911_20201229172349.jpg,73792589_5911_20201229172349.jpg,73792589_5911_20201229172349.jpg,73792589_5911_20201229172349.jpg","avaliacao":0,"preco_de":159,"preco_por":143.1}I tried to update the field mapping to reference my custom analyzer
Problem: When trying to proceed with step 3, the following error is returned to me:
[REQUEST] _mapping
{
"properties": {
"name": {
"type": "text",
"analyzer": "autocomplete",
"search_analyzer": "autocomplete_search",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"sku": {
"type": "text",
"analyzer": "autocomplete",
"search_analyzer": "autocomplete_search",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
[RESPONSE]
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Mapper for [name] conflicts with existing mapper:\n\tCannot update parameter [analyzer] from [default] to [autocomplete]"
}
],
"type": "illegal_argument_exception",
"reason": "Mapper for [name] conflicts with existing mapper:\n\tCannot update parameter [analyzer] from [default] to [autocomplete]"
},
"status": 400
}