The results of two same query string queries with quoted phrases return different results if one query is wrapped inside a function_score
query. In the wrapped query, the phrase isn't preserved in full but tokenized, which can be seen by the highlighted results.
QueryA:
GET consolidated-index991/_search
{
"from": 0,
"highlight": {
"fields": {
"content": {}
},
"max_analyzed_offset": 999999,
"number_of_fragments": 5
},
"query": {
"function_score": {
"query": {
"query_string": {
"analyzer": "cg_analyzer_naziv",
"fields": [
"content"
],
"query": "\"savo pejovic\"",
"boost": 3
}
}
}
},
"size": 10,
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"_source": {
"includes": [
"genericReference",
"isActive"
]
}
}
QueryB:
{
"from": 0,
"highlight": {
"fields": {
"content": {}
},
"max_analyzed_offset": 999999,
"number_of_fragments": 5
},
"query": {
"query_string": {
"analyzer": "cg_analyzer_naziv",
"fields": [
"content"
],
"query": "\"savo pejovic\"",
"boost": 3
}
},
"size": 10,
"sort": [
{
"_score": {
"order": "desc"
}
}
],
"_source": {
"includes": [
"genericReference",
"isActive"
]
}
}
QueryA returns hits that highlight just one of these tokens, while QueryB only returns hits with exact phrase hihglighted.
How to make QueryA behave like QueryB?