|
@@ -18,7 +18,6 @@
|
|
|
*/
|
|
|
package org.elasticsearch.search.functionscore;
|
|
|
|
|
|
-import org.apache.lucene.search.Explanation;
|
|
|
import org.elasticsearch.action.search.SearchResponse;
|
|
|
import org.elasticsearch.index.query.functionscore.random.RandomScoreFunctionBuilder;
|
|
|
import org.elasticsearch.search.SearchHit;
|
|
@@ -37,7 +36,7 @@ import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.
|
|
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
|
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
|
|
|
import static org.hamcrest.Matchers.*;
|
|
|
-import static org.hamcrest.Matchers.arrayContaining;
|
|
|
+
|
|
|
|
|
|
public class RandomScoreFunctionTests extends ElasticsearchIntegrationTest {
|
|
|
|
|
@@ -179,6 +178,17 @@ public class RandomScoreFunctionTests extends ElasticsearchIntegrationTest {
|
|
|
assertThat(firstHit.explanation().toString(), containsString("" + seed));
|
|
|
}
|
|
|
|
|
|
+ public void testNoDocs() throws Exception {
|
|
|
+ createIndex("test");
|
|
|
+ ensureGreen();
|
|
|
+
|
|
|
+ SearchResponse resp = client().prepareSearch("test")
|
|
|
+ .setQuery(functionScoreQuery(matchAllQuery(), randomFunction(1234)))
|
|
|
+ .get();
|
|
|
+ assertNoFailures(resp);
|
|
|
+ assertEquals(0, resp.getHits().totalHits());
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testScoreRange() throws Exception {
|
|
|
// all random scores should be in range [0.0, 1.0]
|