Skip to content

Commit 5616bc6

Browse files
committed
Check IVF feature flag to retrieve valid index types
1 parent a952245 commit 5616bc6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,6 @@ tests:
565565
- class: org.elasticsearch.test.apmintegration.TracesApmIT
566566
method: testApmIntegration
567567
issue: https://github.com/elastic/elasticsearch/issues/129651
568-
- class: org.elasticsearch.search.query.RescoreKnnVectorQueryIT
569-
method: testKnnSearchRescore
570-
issue: https://github.com/elastic/elasticsearch/issues/129713
571568
- class: org.elasticsearch.snapshots.SnapshotShutdownIT
572569
method: testSnapshotShutdownProgressTracker
573570
issue: https://github.com/elastic/elasticsearch/issues/129752

server/src/internalClusterTest/java/org/elasticsearch/search/query/RescoreKnnVectorQueryIT.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.action.search.SearchResponse;
1616
import org.elasticsearch.cluster.metadata.IndexMetadata;
1717
import org.elasticsearch.common.settings.Settings;
18+
import org.elasticsearch.common.util.FeatureFlag;
1819
import org.elasticsearch.index.IndexVersion;
1920
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
2021
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.VectorIndexType;
@@ -33,6 +34,7 @@
3334
import org.elasticsearch.search.vectors.KnnVectorQueryBuilder;
3435
import org.elasticsearch.search.vectors.RescoreVectorBuilder;
3536
import org.elasticsearch.test.ESIntegTestCase;
37+
import org.elasticsearch.test.TestCluster;
3638
import org.elasticsearch.xcontent.XContentBuilder;
3739
import org.elasticsearch.xcontent.XContentFactory;
3840
import org.junit.Before;
@@ -42,13 +44,17 @@
4244
import java.util.Arrays;
4345
import java.util.Collection;
4446
import java.util.Collections;
47+
import java.util.HashSet;
4548
import java.util.List;
4649
import java.util.Locale;
4750
import java.util.Map;
51+
import java.util.Set;
4852
import java.util.function.BiFunction;
4953
import java.util.function.Function;
5054
import java.util.stream.Collectors;
5155

56+
import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.IVF_FORMAT;
57+
import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.VectorIndexType.BBQ_IVF;
5258
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
5359
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailuresAndResponse;
5460
import static org.hamcrest.Matchers.equalTo;
@@ -83,11 +89,15 @@ protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() {
8389

8490
@Before
8591
public void setup() throws IOException {
92+
Set<String> validIndexTypes = Arrays.stream(VectorIndexType.values())
93+
.filter(VectorIndexType::isQuantized)
94+
.map(t -> t.name().toLowerCase(Locale.ROOT))
95+
.collect(Collectors.toCollection(HashSet::new));
96+
if (IVF_FORMAT.isEnabled() == false) {
97+
validIndexTypes.remove(BBQ_IVF.name().toLowerCase(Locale.ROOT));
98+
}
8699
String type = randomFrom(
87-
Arrays.stream(VectorIndexType.values())
88-
.filter(VectorIndexType::isQuantized)
89-
.map(t -> t.name().toLowerCase(Locale.ROOT))
90-
.collect(Collectors.toCollection(ArrayList::new))
100+
validIndexTypes
91101
);
92102
XContentBuilder mapping = XContentFactory.jsonBuilder()
93103
.startObject()

0 commit comments

Comments
 (0)