From a76ec765e55c1a8e83666ec9f5474b979be80e6e Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Wed, 26 Feb 2020 10:51:28 +0000 Subject: [PATCH] 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 --- .../elasticsearch/percolator/PercolatorQuerySearchIT.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java index 79b2314faaf22..b32416b69fb44 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchIT.java @@ -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()),