diff --git a/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java b/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java index 8992e3ad4bc..1485240998f 100644 --- a/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java +++ b/src/test/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java @@ -244,5 +244,45 @@ public class CustomScoreSearchTests extends AbstractNodesTests { assertThat(searchResponse.hits().getAt(1).id(), equalTo("1")); assertThat(searchResponse.hits().getAt(1).score(), equalTo(4.0f)); logger.info("--> Hit[1] {} Explanation {}", searchResponse.hits().getAt(1).id(), searchResponse.hits().getAt(1).explanation()); + + searchResponse = client.prepareSearch("test") + .setQuery(customFiltersScoreQuery(matchAllQuery()).scoreMode("min") + .add(termFilter("field", "value4"), 2) + .add(termFilter("field", "value1"), 3) + .add(termFilter("color", "red"), 5)) + .setExplain(true) + .execute().actionGet(); + + assertThat(Arrays.toString(searchResponse.shardFailures()), searchResponse.failedShards(), equalTo(0)); + assertThat(searchResponse.hits().totalHits(), equalTo(4l)); + assertThat(searchResponse.hits().getAt(0).id(), equalTo("3")); + assertThat(searchResponse.hits().getAt(0).score(), equalTo(5.0f)); + logger.info("--> Hit[0] {} Explanation {}", searchResponse.hits().getAt(0).id(), searchResponse.hits().getAt(0).explanation()); + assertThat(searchResponse.hits().getAt(1).id(), equalTo("1")); + assertThat(searchResponse.hits().getAt(1).score(), equalTo(3.0f)); + assertThat(searchResponse.hits().getAt(2).id(), equalTo("4")); + assertThat(searchResponse.hits().getAt(2).score(), equalTo(2.0f)); + assertThat(searchResponse.hits().getAt(3).id(), equalTo("2")); + assertThat(searchResponse.hits().getAt(3).score(), equalTo(1.0f)); + + searchResponse = client.prepareSearch("test") + .setQuery(customFiltersScoreQuery(matchAllQuery()).scoreMode("multiply") + .add(termFilter("field", "value4"), 2) + .add(termFilter("field", "value1"), 3) + .add(termFilter("color", "red"), 5)) + .setExplain(true) + .execute().actionGet(); + + assertThat(Arrays.toString(searchResponse.shardFailures()), searchResponse.failedShards(), equalTo(0)); + assertThat(searchResponse.hits().totalHits(), equalTo(4l)); + assertThat(searchResponse.hits().getAt(0).id(), equalTo("1")); + assertThat(searchResponse.hits().getAt(0).score(), equalTo(15.0f)); + logger.info("--> Hit[0] {} Explanation {}", searchResponse.hits().getAt(0).id(), searchResponse.hits().getAt(0).explanation()); + assertThat(searchResponse.hits().getAt(1).id(), equalTo("3")); + assertThat(searchResponse.hits().getAt(1).score(), equalTo(5.0f)); + assertThat(searchResponse.hits().getAt(2).id(), equalTo("4")); + assertThat(searchResponse.hits().getAt(2).score(), equalTo(2.0f)); + assertThat(searchResponse.hits().getAt(3).id(), equalTo("2")); + assertThat(searchResponse.hits().getAt(3).score(), equalTo(1.0f)); } } \ No newline at end of file