I am trying to search for words like - “on time”, “on-time” and "on." I am using whitespace analyzer to get the exact result and using phrase rather than text as I need the word together, but it is not giving me accurate result it gave me some result which has only “on”
{
"analyzer": "lucene.whitespace",
"searchAnalyzer": "lucene.whitespace",
"mappings": {
"dynamic": false,
"fields": {
"client": {
"type": "string"
},
"fulltext": {
"type": "string"
},
"dateRange": {
"type": "date"
}
}
}
}
and My search query is like this -
[
{
"$search":{
"index":"fulltext",
"compound":{
"filter":{
"range":{
"path":"dateRange",
"gte":"ISODate(""2023-03-01T00:00:00.000Z"")",
"lte":"ISODate(""2023-03-31T18:29:59.000Z"")"
}
},
"must":{
"phrase":{
"query":"ABC",
"path":[
"client"
]
}
},
"should":[
{
"phrase":{
"query":"on-time",
"path":[
"fulltext"
]
}
},
{
"phrase":{
"query":"on time",
"path":[
"fulltext"
]
}
}
]
}
}
}
]
Why I am getting a result also without the phrase “on time” , I mean data which has on will also included in result why ?