Hi,
I hope anyone could help us to develop the right way to solve our little problems with synonyms and wildcards in elastic search.
We are using a synonym list at our search to identified all relevant typings of users at our website. Without wildcard everything works fine, like:
curl -XGET --noproxy es01.liqui-moly.com.local:9200, 'es01.liqui-moly.com.local:9200/limo_b2c_de_idx2/_validate/query?explain&pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"must": {
"query_string": {
"query": "vw50200",
"default_operator": "and",
"analyze_wildcard": true,
"allow_leading_wildcard": true,
"split_on_whitespace": false,
"fields": [
"name^5",
"sku",
"description",
"short_description",
"viscosity",
"all_approvals_recoms",
"keywords"
]
}
}
}
}
}
'
An user typed in vw50200 and he got our page for VW 502 00.
{
"valid" : true,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"explanations" : [
{
"index" : "limo_b2c_de_idx2",
"valid" : true,
"explanation" : "+(Synonym(all_approvals_recoms:VW 502 00 all_approvals_recoms:vw50200) | Synonym(description:VW 502 00 description:vw50200) | Synonym(keywords:VW 502 00 keywords:vw50200) | (Synonym(name:VW 502 00 name:vw50200))^5.0 | Synonym(short_description:VW 502 00 short_description:vw50200) | sku:vw50200 | Synonym(viscosity:VW 502 00 viscosity:vw50200))"
}
]
}
But if we combinded this search with wildcards our synonym search is not longer working. Look at this case to search for *vw50200*
:
curl -XGET --noproxy es01.liqui-moly.com.local:9200, 'es01.liqui-moly.com.local:9200/limo_b2c_de_idx2/_validate/query?explain&pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"must": {
"query_string": {
"query": "*vw50200*",
"default_operator": "and",
"analyze_wildcard": true,
"allow_leading_wildcard": true,
"split_on_whitespace": false,
"fields": [
"name^5",
"sku",
"description",
"short_description",
"viscosity",
"all_approvals_recoms",
"keywords"
]
}
}
}
}
}
'
We got no result
"valid" : true,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"explanations" : [
{
"index" : "limo_b2c_de_idx2",
"valid" : true,
"explanation" : "+(all_approvals_recoms:*vw50200* | description:*vw50200* | keywords:*vw50200* | (name:*vw50200*)^5.0 | short_description:*vw50200* | sku:*vw50200* | viscosity:*vw50200*)"
}
]
}
Finally the all important question is: Is there a trick to work with wildcards and synonyms in ES ?
Thanks for your help and if you need any further informations I will handle this as soon as possible