Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Apr 24, 2024
1 parent c1fb5e3 commit fe3bd86
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ tasks.named("yamlRestTestV7CompatTransform").configure { task ->
task.skipTest("search/370_profile/fetch source", "profile output has changed")
task.skipTest("search/370_profile/fetch nested source", "profile output has changed")
task.skipTest("search/240_date_nanos/doc value fields are working as expected across date and date_nanos fields", "Fetching docvalues field multiple times is no longer allowed")
task.skipTest("search/110_field_collapsing/field collapsing and rescore", "#107779 Field collapsing is compatible with rescore in 8.15")

task.replaceValueInMatch("_type", "_doc")
task.addAllowedWarningRegex("\\[types removal\\].*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,11 @@ public void testRescoreAfterCollapseRandom() throws Exception {
float bestScore = groups[group] == null ? -1 : groups[group].firstPassScore;
var groupDoc = new GroupDoc(id, Integer.toString(group), firstPassScore, secondPassScore, shouldFilter);
if (shouldFilter == false) {
if (firstPassScore == bestScore) {
// avoid tiebreaker
continue;
}

numHits++;
if (firstPassScore > bestScore) {
groups[group] = groupDoc;
Expand All @@ -952,21 +957,23 @@ public void testRescoreAfterCollapseRandom() throws Exception {

GroupDoc[] sortedGroups = Arrays.stream(groups)
.filter(g -> g != null)
.sorted(Comparator.comparingDouble(GroupDoc::secondPassScore))
.sorted(Comparator.comparingDouble(GroupDoc::secondPassScore).reversed())
.toArray(GroupDoc[]::new);

var request = client().prepareSearch("test")
.setQuery(fieldValueScoreQuery("firstPassScore"))
.addRescorer(new QueryRescorerBuilder(fieldValueScoreQuery("secondPassScore")).windowSize(numGroups))
.addRescorer(new QueryRescorerBuilder(fieldValueScoreQuery("secondPassScore"))
.setQueryWeight(0f)
.windowSize(numGroups))
.setCollapse(new CollapseBuilder("group"))
.setSize(Math.min(numGroups, 10));
long expectedNumHits = numHits;
assertResponse(request, resp -> {
assertThat(resp.getHits().getTotalHits().value, equalTo(expectedNumHits));
for (int pos = 0; pos < resp.getHits().getHits().length; pos++) {
SearchHit hit = resp.getHits().getAt(pos);
assertThat(hit.getId(), equalTo(groups[pos].id()));
int group = Integer.valueOf(hit.field("group").getValue());
assertThat(hit.getId(), equalTo(sortedGroups[pos].id()));
String group = hit.field("group").getValue();
assertThat(group, equalTo(sortedGroups[pos].group()));
assertThat(hit.getScore(), equalTo(sortedGroups[pos].secondPassScore));
}
Expand Down
1 change: 1 addition & 0 deletions x-pack/qa/runtime-fields/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ subprojects {
'aggregations/range/Date range', //source only date field should also emit values for numbers, it expects strings only
'search/115_multiple_field_collapsing/two levels fields collapsing', // Field collapsing on a runtime field does not work
'search/111_field_collapsing_with_max_score/*', // Field collapsing on a runtime field does not work
'search/112_field_collapsing_with_rescore/*', // Field collapsing on a runtime field does not work
'field_caps/30_index_filter/Field caps with index filter', // We don't support filtering field caps on runtime fields. What should we do?
'search/350_point_in_time/point-in-time with index filter', // We don't support filtering pit on runtime fields.
'aggregations/filters_bucket/cache busting', // runtime keyword does not support split_queries_on_whitespace
Expand Down

0 comments on commit fe3bd86

Please sign in to comment.