'Elastic search doesn't find document with "-" in it
I have a query in ES:
POST <index>/_search
{
"_source":[
<list_of_fields_to_return>
],
"size":"6",
"from":"0",
"min_score": 10,
"query":{
"function_score":{
"functions":[
{
"field_value_factor":{
"field":"product.sales_count",
"missing":0,
"modifier":"log1p"
}
},
{
"field_value_factor":{
"field":"product.image_count",
"missing":0,
"modifier":"log1p"
}
},
{
"field_value_factor":{
"field":"featureCount",
"missing":0,
"modifier":"log1p"
}
},
{
"field_value_factor":{
"field":"<field>",
"missing":0,
"modifier":"none",
"factor":5
}
},
{
"field_value_factor":{
"field":"<field>",
"missing":0,
"modifier":"none",
"factor":3
}
},
{
"field_value_factor":{
"field":"<field>",
"missing":0,
"modifier":"none",
"factor":2
}
},
{
"field_value_factor":{
"field":"<field>",
"missing":0,
"modifier":"none",
"factor":2
}
},
{
"field_value_factor":{
"field":"<field>",
"missing":0,
"modifier":"none",
"factor":1
}
}
],
"score_mode":"sum",
"query":{
"bool":{
"filter":[
{
"term":{
"product.is_visible":true
}
}
],
"should":[
{
"query_string":{
"fields":[
<field>
],
"query":"ALV3002688-SET~1"
}
},
{
"query_string":{
"fields":[
"<field>"
],
"query":"ALV3002688-SET",
"boost":"2.0"
}
},
{
"query_string":{
"fields":[
"product.ref"
],
"query":"*ALV3002688-SET*", <---- PROBLEM WITH "-" sign
"boost": 10
}
}
]
}
}
}
},
"aggs":{
"by_categories":{
"terms":{
"field":"<field>"
}
}
}
}
If i strip the "-SET", it matches perfectly, can't wildcard search for "-"? For now, it just returns 0 matching documents. I could do something like, strip "-" and replace it with whitespace but then It gives me all documents for example "something\SET".
Also, If I remove the "*" sign it maches perfectly.
What am I missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
