[TEST] Simplify SearchQueryIT#testMinScore

This test used indexRandom to index 4 documents. indexRandom introduces also bogus documents which were getting on the way now that we use fieldValueFactor instead of a script to determine the script of the documents. Taken out indexRandom to simplify things and make the tests more predictable.
This commit is contained in:
javanna 2015-10-06 10:17:59 +02:00 committed by Luca Cavanna
parent 2fd1cde35e
commit d618a602ab

View File

@ -1933,14 +1933,14 @@ public class SearchQueryIT extends ESIntegTestCase {
public void testMinScore() throws ExecutionException, InterruptedException {
createIndex("test");
indexRandom(true,
client().prepareIndex("test", "test", "1").setSource("score", 1.5),
client().prepareIndex("test", "test", "2").setSource("score", 1.0),
client().prepareIndex("test", "test", "3").setSource("score", 2.0),
client().prepareIndex("test", "test", "4").setSource("score", 0.5));
client().prepareIndex("test", "test", "1").setSource("score", 1.5).get();
client().prepareIndex("test", "test", "2").setSource("score", 1.0).get();
client().prepareIndex("test", "test", "3").setSource("score", 2.0).get();
client().prepareIndex("test", "test", "4").setSource("score", 0.5).get();
refresh();
SearchResponse searchResponse = client().prepareSearch("test").setQuery(
functionScoreQuery(ScoreFunctionBuilders.fieldValueFactorFunction("score")).setMinScore(1.5f)).get();
functionScoreQuery(ScoreFunctionBuilders.fieldValueFactorFunction("score").missing(1.0)).setMinScore(1.5f)).get();
assertHitCount(searchResponse, 2);
assertFirstHit(searchResponse, hasId("3"));
assertSecondHit(searchResponse, hasId("1"));