Ensure that percolator sorting also works (#52758)

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
This commit is contained in:
Alan Woodward 2020-02-26 10:51:28 +00:00
parent f57422bbfd
commit a76ec765e5
1 changed files with 5 additions and 0 deletions

View File

@ -967,6 +967,11 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
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()),