Reputation: 1653
We have an issue in Elastic Search whereby it doesn't seem to escape the slash in a query and seems to match cases even if they are exact matches.
These are the 2 cases in the database:
Case1:
caseReference: AB/19/001
Case2:
caseReference: AB/20/001
Running a query searching for AB/20/001 returns case1 and case2 when we was only expecting case2.
This is the query we are posting:
{"query":{
"match":{
"data.caseReference":{
"query":"AB\\/20\\/001",
"operator":"OR",
"fuzzy_transpositions":true,
"lenient":false
}
}
}
}
Any idea what is wrong?
Upvotes: 0
Views: 249
Reputation: 217284
You need to use the AND
operator and also escape the backslash, too
{"query":{
"match":{
"data.caseReference":{
"query":"AB\\/20\\/001",
"operator":"AND",
"fuzzy_transpositions":true,
"lenient":false
}
}
}
}
Upvotes: 1
Reputation: 16172
You need to use operator AND
Search Query:
{
"query": {
"match": {
"data.caseReference": {
"query": "AB\\/20\\/001",
"operator": "AND",
"fuzzy_transpositions": true,
"lenient": false
}
}
}
}
Search Result
"hits": [
{
"_index": "64773199",
"_type": "_doc",
"_id": "2",
"_score": 1.0577903,
"_source": {
"data.caseReference": "AB/20/001"
}
}
]
Upvotes: 1