Skip to content

Commit 7a0f261

Browse files
authored
Test fix for PinnedQueryBuilderIT (#46187)
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
1 parent d980b61 commit 7a0f261

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

x-pack/plugin/search-business-rules/src/test/java/org/elasticsearch/xpack/searchbusinessrules/PinnedQueryBuilderIT.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.LinkedHashSet;
2424
import java.util.List;
2525

26+
import static org.elasticsearch.action.search.SearchType.DFS_QUERY_THEN_FETCH;
2627
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
2728
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
2829
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFirstHit;
@@ -56,13 +57,12 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
5657
return plugins;
5758
}
5859

59-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/46174")
6060
public void testPinnedPromotions() throws Exception {
6161
assertAcked(prepareCreate("test")
6262
.addMapping("type1",
6363
jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("field1")
6464
.field("analyzer", "whitespace").field("type", "text").endObject().endObject().endObject().endObject())
65-
.setSettings(Settings.builder().put(indexSettings()).put("index.number_of_shards", 2)));
65+
.setSettings(Settings.builder().put(indexSettings()).put("index.number_of_shards", randomIntBetween(2, 5))));
6666

6767
int numRelevantDocs = randomIntBetween(1, 100);
6868
for (int i = 0; i < numRelevantDocs; i++) {
@@ -102,6 +102,7 @@ public void testPinnedPromotions() throws Exception {
102102
int from = randomIntBetween(0, numRelevantDocs);
103103
int size = randomIntBetween(10, 100);
104104
SearchResponse searchResponse = client().prepareSearch().setQuery(pqb).setTrackTotalHits(true).setSize(size).setFrom(from)
105+
.setSearchType(DFS_QUERY_THEN_FETCH)
105106
.get();
106107

107108
long numHits = searchResponse.getHits().getTotalHits().value;

0 commit comments

Comments
 (0)