Fix test issue to stabilise scoring through use of DFS search mode. Randomised index-then-delete docs introduced by the test framework likely caused an imbalance in IDF scores across shards. Also made number of shards used in test a random number for added test coverage. Closes #46174
This commit is contained in:
parent
d68e05aade
commit
a9e3871fc7
|
@ -23,6 +23,7 @@ import java.util.Collection;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.elasticsearch.action.search.SearchType.DFS_QUERY_THEN_FETCH;
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFirstHit;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFirstHit;
|
||||||
|
@ -61,7 +62,7 @@ public class PinnedQueryBuilderIT extends ESIntegTestCase {
|
||||||
.addMapping("type1",
|
.addMapping("type1",
|
||||||
jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1")
|
jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1")
|
||||||
.field("analyzer", "whitespace").field("type", "text").endObject().endObject().endObject().endObject())
|
.field("analyzer", "whitespace").field("type", "text").endObject().endObject().endObject().endObject())
|
||||||
.setSettings(Settings.builder().put(indexSettings()).put("index.number_of_shards", 2)));
|
.setSettings(Settings.builder().put(indexSettings()).put("index.number_of_shards", randomIntBetween(2, 5))));
|
||||||
|
|
||||||
int numRelevantDocs = randomIntBetween(1, 100);
|
int numRelevantDocs = randomIntBetween(1, 100);
|
||||||
for (int i = 0; i < numRelevantDocs; i++) {
|
for (int i = 0; i < numRelevantDocs; i++) {
|
||||||
|
@ -101,6 +102,7 @@ public class PinnedQueryBuilderIT extends ESIntegTestCase {
|
||||||
int from = randomIntBetween(0, numRelevantDocs);
|
int from = randomIntBetween(0, numRelevantDocs);
|
||||||
int size = randomIntBetween(10, 100);
|
int size = randomIntBetween(10, 100);
|
||||||
SearchResponse searchResponse = client().prepareSearch().setQuery(pqb).setTrackTotalHits(true).setSize(size).setFrom(from)
|
SearchResponse searchResponse = client().prepareSearch().setQuery(pqb).setTrackTotalHits(true).setSize(size).setFrom(from)
|
||||||
|
.setSearchType(DFS_QUERY_THEN_FETCH)
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
long numHits = searchResponse.getHits().getTotalHits().value;
|
long numHits = searchResponse.getHits().getTotalHits().value;
|
||||||
|
|
Loading…
Reference in New Issue