"settings": {
"index": {
"analysis": {
"filter": {
"first_name_synonym_filter": {
"type": "synonym",
"synonyms": [
"aaron,erin,ronnie,ron",
"abbie,abby,abigail",
etc..
]
},
"prefix_filter": {
"type": "edgeNGram",
"max_gram": "30"
},
"alphanum_filter": {
"pattern": "\\W",
"type": "pattern_replace",
"replacement": ""
}
},
"analyzer": {
"basic_analyzer": {
"filter": [
"standard",
"lowercase",
"asciifolding",
"alphanum_filter"
],
"type": "custom",
"tokenizer": "uax_url_email"
},
"first_name_synonym_analyzer": {
"filter": [
"standard",
"lowercase",
"asciifolding",
"alphanum_filter",
"first_name_synonym_filter"
],
"type": "custom",
"tokenizer": "uax_url_email"
},
"basic_analyzer_prefix": {
"filter": [
"standard",
"lowercase",
"asciifolding",
"alphanum_filter",
"prefix_filter"
],
"type": "custom",
"tokenizer": "uax_url_email"
}
}
}
}
"mappings": {
"Consumer": {
"_all": {
"enabled": false
},
"properties": {
"Email": {
"type": "text",
"fields": {
"Prefix": {
"type": "text",
"analyzer": "basic_analyzer_prefix",
"search_analyzer": "basic_analyzer"
}
},
"analyzer": "basic_analyzer"
},
"FirstName": {
"type": "text",
"fields": {
"Synonym": {
"type": "text",
"analyzer": "first_name_synonym_analyzer",
"search_analyzer": "basic_analyzer"
}
},
"copy_to": [
"FullName"
],
"analyzer": "basic_analyzer"
},
"FullName": {
"type": "text",
"fields": {
"Prefix": {
"type": "text",
"analyzer": "basic_analyzer_prefix",
"search_analyzer": "basic_analyzer"
}
},
"analyzer": "basic_analyzer"
},
"LastName": {
"type": "text",
"fields": {
"Exact": {
"type": "keyword"
}
},
"copy_to": [
"FullName"
],
"analyzer": "basic_analyzer"
}
}
}
}
Thanks for the reply, I understood what you are pointing to, it's really helpful.
The above is my setting and mapping, I am confused how I can use your suggestion.
My query is:
"query": {
"bool": { "should": [
{"match": {
"FullName.Prefix": { "query": "Ryan" }}},
{"match": {
"Email.Prefix": { "query": "Ryan" }}}
],
"minimum_should_match": 1}},
"highlight": {
"fields": {
"FirstName": {"require_field_match": false},
"LastName": {"require_field_match": false},
"Email": {"require_field_match": false},
}
}
Do i need to implement a prefix analyzer for each of these fields to highlight?
Is there an alternate way to achieve this!!