Skip to content

Commit

Permalink
Ensure that percolator sorting also works (#52758)
Browse files Browse the repository at this point in the history
Commit #52748 fixed a bug where percolate queries wrapped in a constant score
could report incorrect matches. This commit adds a test to check that it also fixes
the case where a percolate query is sorted by something other than score.

Closes #52618
  • Loading branch information
romseygeek committed Feb 26, 2020
1 parent f57422b commit a76ec76
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,11 @@ public void testWrappedWithConstantScore() throws Exception {
BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()),
XContentType.JSON)).get();
assertEquals(1, response.getHits().getTotalHits().value);

response = client().prepareSearch("test").setQuery(new PercolateQueryBuilder("q",
BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()),
XContentType.JSON)).addSort("_doc", SortOrder.ASC).get();
assertEquals(1, response.getHits().getTotalHits().value);

response = client().prepareSearch("test").setQuery(constantScoreQuery(new PercolateQueryBuilder("q",
BytesReference.bytes(jsonBuilder().startObject().field("d", "2020-02-01T15:00:00.000+11:00").endObject()),
Expand Down

0 comments on commit a76ec76

Please sign in to comment.