|
15 | 15 | import org.elasticsearch.action.search.SearchResponse; |
16 | 16 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
17 | 17 | import org.elasticsearch.common.settings.Settings; |
| 18 | +import org.elasticsearch.common.util.FeatureFlag; |
18 | 19 | import org.elasticsearch.index.IndexVersion; |
19 | 20 | import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; |
20 | 21 | import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.VectorIndexType; |
|
33 | 34 | import org.elasticsearch.search.vectors.KnnVectorQueryBuilder; |
34 | 35 | import org.elasticsearch.search.vectors.RescoreVectorBuilder; |
35 | 36 | import org.elasticsearch.test.ESIntegTestCase; |
| 37 | +import org.elasticsearch.test.TestCluster; |
36 | 38 | import org.elasticsearch.xcontent.XContentBuilder; |
37 | 39 | import org.elasticsearch.xcontent.XContentFactory; |
38 | 40 | import org.junit.Before; |
|
42 | 44 | import java.util.Arrays; |
43 | 45 | import java.util.Collection; |
44 | 46 | import java.util.Collections; |
| 47 | +import java.util.HashSet; |
45 | 48 | import java.util.List; |
46 | 49 | import java.util.Locale; |
47 | 50 | import java.util.Map; |
| 51 | +import java.util.Set; |
48 | 52 | import java.util.function.BiFunction; |
49 | 53 | import java.util.function.Function; |
50 | 54 | import java.util.stream.Collectors; |
51 | 55 |
|
| 56 | +import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.IVF_FORMAT; |
| 57 | +import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.VectorIndexType.BBQ_IVF; |
52 | 58 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; |
53 | 59 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailuresAndResponse; |
54 | 60 | import static org.hamcrest.Matchers.equalTo; |
@@ -83,11 +89,15 @@ protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() { |
83 | 89 |
|
84 | 90 | @Before |
85 | 91 | 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 | + } |
86 | 99 | 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 |
91 | 101 | ); |
92 | 102 | XContentBuilder mapping = XContentFactory.jsonBuilder() |
93 | 103 | .startObject() |
|
0 commit comments