Can I have multiple filters in an Elasticsearch index's settings? -
i want elasticsearch index stores "names" of features. want able issue phonetic queries , type-ahead style queries separately. think able create 1 index 2 analyzers , 2 filters; each analyzer use 1 of filters. not seem able this.
here index settings json i'm trying use:
{ "settings": { "number_of_shards": 1, "analysis": { "analyzer": { "autocomplete_analyzer": { "type": "custom", "tokenizer": "standard", "filter": ["standard", "lowercase", "ngram"] } }, "analyzer": { "phonetic_analyzer": { "tokenizer": "standard", "filter": "double_metaphone_filter" } }, "filter": { "double_metaphone_filter": { "type": "phonetic", "encoder": "double_metaphone" } }, "filter": { "ngram": { "type": "ngram", "min_gram": 2, "max_gram": 15 } } } } }
when attempt create index these settings:
http://hostname:9200/index/type
i http 400, saying
custom analyzer [phonetic_analyzer] failed find filter under name [double_metaphone_filter]
don't me wrong, realize sentence means. looked , looked erroneous comma or quote don't see any. otherwise, there , formatted correctly.
if delete phonetic analyzer, index created autocomplete analyzer , ngram filter.
if delete ngram filter, index created phonetic analyzer , phonetic filter.
i have feeling i'm missing fundamental concept of es, 1 analyzer per index, or 1 filter per index, or must have other logical dependencies set correctly, etc. sure nice have logical diagram or complete api spec of elasticsearch infrastructure, i.e. index can have 1..n analyzers, 1 filter, query must need 1 of bool, match, etc. unicorn not seem exist.
i see tons of documentation, blog posts, etc on how each of these functionalities, 1 analyzer , 1 filter on index. i'd dual functionality on 1 index (for reasons out of scope).
can offer help, advice here?
you missing proper formatting settings object. cannot have 2 analyzer
or filter
keys, there can 1 value per key in settings map object. providing list of filters seems work fine. when creating index object, second key overriding first.
look here:
"settings": { "number_of_shards": 1, "analysis": { "filter": { "double_metaphone_filter": { "type": "phonetic", "encoder": "double_metaphone" }, "ngram": { "type": "ngram", "min_gram": 2, "max_gram": 15 } }, "analyzer": { "autocomplete_analyzer": { "type": "custom", "tokenizer": "standard", "filter": ["standard", "lowercase", "ngram"] }, "phonetic_analyzer": { "tokenizer": "standard", "filter": "double_metaphone_filter" } } } }
i downloaded plugin confirm works. can test out @ _analyze
enpoint payload:
{ "analyzer":"autocomplete_analyzer", "text":"jonnie smythe" }