Hello,
I am using Elasticsearch in Magento.
Elasticsearch version 5.6
Magento Enterprise 2.2.9
I have set the sku type to keyword but getting a different result when query has escape character
"sku": {
"type": "keyword"
}
- Magento Query with \:
{
"match": {
"sku": {
"query": "414\-123",
"operator": "OR",
"prefix_length": 0,
"max_expansions": 50,
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"boost": 2
}
}
}
Result:
{
"hits": {
"total": 0,
"max_score": null,
"hits":
}
}
- Removing //
{
"match": {
"sku": {
"query": "414-123",
"operator": "OR",
"prefix_length": 0,
"max_expansions": 50,
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"boost": 2
}
}
}
"hits": {
"total": 1,
"max_score": 0.8630463,
"hits": [
{
"_index": "magento2_product_1_v40",
"_type": "document",
"_id": "1",
"_score": 0.8630463
}
]
}
The analyzer also shows same result so I was wondering why Elasticsearch is not returning the result when the - is escaped with \.
{
"analyzer" : "standard",
"text" : "414\-123"
}
{
"analyzer" : "standard",
"text" : "414-123"
}
Both return the same result
{
"tokens": [
{
"token": "414",
"start_offset": 0,
"end_offset": 3,
"type": "",
"position": 0
},
{
"token": "123",
"start_offset": 5,
"end_offset": 8,
"type": "",
"position": 1
}
]
}