I have created an index with analyzers stemmer and synonym.
I have added a mapping for a field which contains these two analyzers.
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"my_stemmer": {
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"custom_english_stemmer"
]
},
"myr_synonym": {
"tokenizer": "whitespace",
"filter": [
"synonym"
]
}
},
"filter": {
"custom_english_stemmer": {
"type": "stemmer",
"name": "english"
},
"synonym": {
"type": "synonym",
"format": "wordnet",
"synonyms_path": "wn_s.pl"
}
}
}
}
},
"mappings": {
"_default_": {
"properties": {
"name": {
"type": "string",
"fields": {
"synonym":{
"type": "string",
"analyzer": "my_synonym"
},
"my_stemmer":{
"type": "string",
"analyzer": "my_stemmer"
}
}
}
}
}
}
}
I am using multi_match query:
E.g. result contains belt in name.
Suppose I queried as :
{
"query": {
"multi_match": {
"query": "knock",
"fields": [
"name.synonym^2",
"name.my_stemmer^2"
]
}
}
}
it will fetch results of belt as knock is synonym for belt.
But if I use "knocks" results are empty. Can I apply both stemmer as well as synonym on single field at a time?