[TEST] Ensure scores are consistent.
This commit is contained in:
parent
1e894111b0
commit
f936283d65
|
@ -2457,27 +2457,26 @@ public class SimpleQueryTests extends ElasticsearchIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void testQueryStringParserCache() throws Exception {
|
public void testQueryStringParserCache() throws Exception {
|
||||||
createIndex("test");
|
createIndex("test");
|
||||||
indexRandom(true, Arrays.asList(
|
indexRandom(true, false, client().prepareIndex("test", "type", "1").setSource("nameTokens", "xyz"));
|
||||||
client().prepareIndex("test", "type", "1").setSource("nameTokens", "xyz")
|
|
||||||
));
|
|
||||||
|
|
||||||
SearchResponse response = client().prepareSearch("test")
|
SearchResponse response = client().prepareSearch("test")
|
||||||
|
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
.setQuery(QueryBuilders.queryString("xyz").boost(100))
|
.setQuery(QueryBuilders.queryString("xyz").boost(100))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||||
assertThat(response.getHits().getAt(0).id(), equalTo("1"));
|
assertThat(response.getHits().getAt(0).id(), equalTo("1"));
|
||||||
|
|
||||||
float score = response.getHits().getAt(0).getScore();
|
float first = response.getHits().getAt(0).getScore();
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
response = client().prepareSearch("test")
|
response = client().prepareSearch("test")
|
||||||
|
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
|
||||||
.setQuery(QueryBuilders.queryString("xyz").boost(100))
|
.setQuery(QueryBuilders.queryString("xyz").boost(100))
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
assertThat(response.getHits().totalHits(), equalTo(1l));
|
assertThat(response.getHits().totalHits(), equalTo(1l));
|
||||||
assertThat(response.getHits().getAt(0).id(), equalTo("1"));
|
assertThat(response.getHits().getAt(0).id(), equalTo("1"));
|
||||||
assertThat(Float.compare(score, response.getHits().getAt(0).getScore()), equalTo(0));
|
float actual = response.getHits().getAt(0).getScore();
|
||||||
|
assertThat(i + " expected: " + first + " actual: " + actual, Float.compare(first, actual), equalTo(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue