Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

unit tests for issue #1560, customfiltersscore min and multiply scoremode #1565

Closed
wants to merge 1 commit into from

2 participants

@jaysonminard

Forgot the unit tests previously. Want these committed before starting on issue #1561

@kimchy
Owner

cheers, pushed.

@kimchy kimchy closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
40 ...st/java/org/elasticsearch/test/integration/search/customscore/CustomScoreSearchTests.java
@@ -244,5 +244,45 @@ public void testCustomFiltersScore() throws Exception {
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));
}
}
Something went wrong with that request. Please try again.