I cannot get search_analyzer to work as expected. I expect it to apply the specified analyzer to the inputed search string and then do the search.
I set the indexed analyzer to an ngram tokenizer with a lowercase filter and a char replacement (- to _)
I then want the search analyzer to lowercase and replace (- to _).
Example document: {"filename": "AAA-BBB"}
Example search that should match: {"match": "AAA-b"}
Instead I have to search using: {"match": "aaa_b"}
elasticsearch version: 5.5
Mapping:
{
"settings": {
"analysis": {
"tokenizer": {
"DO_tokenizer_ngram": {
"type": "ngram",
"min_gram": 2,
"max_gram": 30
}
},
"analyzer": {
"DO_analyzer_ngram": {
"tokenizer": "DO_tokenizer_ngram",
"char_filter": [
"do_char_filter_dashes"
],
"filter": [
"lowercase"
]
},
"DO_analyzer_search": {
"type": "keyword",
"char_filter": [
"do_char_filter_dashes"
],
"filter": [
"lowercase"
]
}
},
"char_filter": {
"do_char_filter_dashes": {
"type": "pattern_replace",
"pattern": "(\\d+)-(?=\\d)",
"replacement": "$1_"
}
}
}
},
"mappings": {
"images": {
"properties": {
"filename": {
"type": "text",
"analyzer": "DO_analyzer_ngram",
"search_analyzer": "DO_analyzer_search"
}
}
}
}
}