Hello! We've got an implementation of ElasticSearch up and running in order to provide basic search in our web app. Our app stores the names and addresses of businesses, along with other relevant information like billing addresses etc. Our users want a very simple search to find a given record, testing their search term against multiple indexed fields.
We thought we had it all sorted by we've been getting complaints about some well known brands (M&S and H&M) not being returned in results.
Presently, our index is setup like this:
body: {
settings: {
index: {
filter: {
autocomplete_filter: {
type: 'edge_ngram',
min_gram: 3,
max_gram: 20,
},
},
analyzer: {
autocomplete: {
type: 'custom',
tokenizer: 'standard',
filter: [
'lowercase',
'autocomplete_filter',
],
},
autocomplete_search: {
type: 'custom',
tokenizer: 'keyword',
filter: 'lowercase',
},
},
},
},
mappings,
}
For each field being indexed, our mapping looks like this:
{
type: 'text',
analyzer: 'autocomplete',
search_analyzer: 'autocomplete_search',
},
Finally, this is an example query:
query: {
multi_match: {
query: 'M&S',
fields: ['tradingName^5', 'address^3', 'billingAddress', 'legalName'],
},
},
I get no hits for "M&S" despite four records in the index having that in their tradingName. I assume the "&" is causing the issue but can't find any documentation that touches on this subject.
Does anyone have thoughts on where I might look for more information, or can you offer guidance what we might be doing wrong here, and how we might improve our setup to get the correct results for our users?
Many thanks for any help you can offer!