Closed krueger closed 6 years ago
This is the rescorer part of the query:
"rescore" : [
{
"query" : {
"rescore_query" : {
"multi_match" : {
"query" : "goz",
"fields" : [
"elements.content.search^1.0",
"elements.tags^1.0",
"elements.title.search^1.0"
],
"type" : "best_fields",
"operator" : "AND",
"slop" : 0,
"prefix_length" : 0,
"max_expansions" : 50,
"lenient" : false,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
},
"query_weight" : 1.0,
"rescore_query_weight" : 1.0,
"score_mode" : "total"
}
},
{
"query" : {
"rescore_query" : {
"multi_match" : {
"query" : "goz",
"fields" : [
"elements.content.stem^1.0",
"elements.tags^1.0",
"elements.title.stem^1.0"
],
"type" : "phrase",
"operator" : "OR",
"slop" : 0,
"prefix_length" : 0,
"max_expansions" : 50,
"lenient" : false,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
},
"query_weight" : 1.0,
"rescore_query_weight" : 80.0,
"score_mode" : "total"
}
},
{
"query" : {
"rescore_query" : {
"match" : {
"elements.content.stem" : {
"query" : "goz",
"operator" : "AND",
"prefix_length" : 0,
"max_expansions" : 50,
"fuzzy_transpositions" : true,
"lenient" : false,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
}
},
"query_weight" : 1.0,
"rescore_query_weight" : 2.0,
"score_mode" : "total"
}
}
]
The problem is that the field _score does not contain the rescore value if result is sorted by score.
This happens when adding requestBuilder.addSort(SortBuilders.scoreSort());
Pinging @elastic/es-search-aggs
@cbuescher could you take a look at this?
Hi @krueger, from the first snippet it looks like you are sorting on different criterea, not just "_score". Am I right, and could you send the whole query you are basing this issue on?
This is the complete query: complete_query.txt
I also checked if there is a difference between requesting _score only and _score with other sort fields. The behavior only occurs if _score with other sort fields is requested.
Hi, did another code and docs search around this and it seems like using "sort" with anything other than "_score" seems to be not supported by design at the moment. The 5.x documentation has a note that "the rescore
phase is not executed when sort
is used." (https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-rescore.html and earlier 5.x versions) while this is relaxed in 6.x and master to say "An error will be thrown if an explicit sort (other than _score) is provided with a rescore query." (https://www.elastic.co/guide/en/elasticsearch/reference/6.x/search-request-rescore.html), which is actually what I get when I try to run a simplified version of your query on 6.3.
I found this issue that introduced throwing that error instead of silently ignoring the rescore phase which dicusses several arguments around why this isn't supported: https://github.com/elastic/elasticsearch/pull/26510
Hope this clears things up and you don't mind me closing this.
Describe the feature:
Elasticsearch version (
bin/elasticsearch --version
): 5.2.2, 5.6.8Plugins installed: []
JVM version (
java -version
): 1.8OS version (
uname -a
if on a Unix-like system): Mac OS X, LinuxDescription of the problem including expected versus actual behavior:
Value in field score is not the same as in explanation
The behavior is not the same as in issue #28725. This time the score value is wrong for values inside the rescorer window.
Steps to reproduce:
Provide logs (if relevant):
Complete explanation: