Skip to content

Commit d030050

Browse files
committed
More feature flag
1 parent d374838 commit d030050

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

server/src/test/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapperTests.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.elasticsearch.index.codec.PerFieldMapperCodec;
3535
import org.elasticsearch.index.codec.vectors.BFloat16;
3636
import org.elasticsearch.index.codec.vectors.diskbbq.ES920DiskBBQVectorsFormat;
37+
import org.elasticsearch.index.codec.vectors.es93.ES93GenericFlatVectorsFormat;
3738
import org.elasticsearch.index.mapper.DocumentMapper;
3839
import org.elasticsearch.index.mapper.DocumentParsingException;
3940
import org.elasticsearch.index.mapper.FieldMapper;
@@ -90,7 +91,9 @@ public class DenseVectorFieldMapperTests extends SyntheticVectorsMapperTestCase
9091
private final int dims;
9192

9293
public DenseVectorFieldMapperTests() {
93-
this.elementType = randomFrom(ElementType.BYTE, ElementType.FLOAT, ElementType.BFLOAT16, ElementType.BIT);
94+
this.elementType = ES93GenericFlatVectorsFormat.GENERIC_VECTOR_FORMAT.isEnabled()
95+
? randomFrom(ElementType.BYTE, ElementType.FLOAT, ElementType.BFLOAT16, ElementType.BIT)
96+
: randomFrom(ElementType.BYTE, ElementType.FLOAT, ElementType.BIT);
9497
this.indexed = usually();
9598
this.indexOptionsSet = this.indexed && randomBoolean();
9699
int baseDims = ElementType.BIT == elementType ? 4 * Byte.SIZE : 4;
@@ -1926,12 +1929,19 @@ public void testKnnVectorsFormat() throws IOException {
19261929
assertThat(codec, instanceOf(LegacyPerFieldMapperCodec.class));
19271930
knnVectorsFormat = ((LegacyPerFieldMapperCodec) codec).getKnnVectorsFormatForField("field");
19281931
}
1929-
String expectedString = "ES93HnswVectorsFormat(name=ES93HnswVectorsFormat, maxConn="
1932+
String expectedString = ES93GenericFlatVectorsFormat.GENERIC_VECTOR_FORMAT.isEnabled()
1933+
? "ES93HnswVectorsFormat(name=ES93HnswVectorsFormat, maxConn="
19301934
+ (setM ? m : DEFAULT_MAX_CONN)
19311935
+ ", beamWidth="
19321936
+ (setEfConstruction ? efConstruction : DEFAULT_BEAM_WIDTH)
19331937
+ ", flatVectorFormat=ES93GenericFlatVectorsFormat(name=ES93GenericFlatVectorsFormat"
1934-
+ ", format=Lucene99FlatVectorsFormat(name=Lucene99FlatVectorsFormat, flatVectorScorer=DefaultFlatVectorScorer())))";
1938+
+ ", format=Lucene99FlatVectorsFormat(name=Lucene99FlatVectorsFormat, flatVectorScorer=DefaultFlatVectorScorer())))"
1939+
:"Lucene99HnswVectorsFormat(name=Lucene99HnswVectorsFormat, maxConn="
1940+
+ (setM ? m : DEFAULT_MAX_CONN)
1941+
+ ", beamWidth="
1942+
+ (setEfConstruction ? efConstruction : DEFAULT_BEAM_WIDTH)
1943+
+ ", flatVectorFormat=Lucene99FlatVectorsFormat(vectorsScorer=DefaultFlatVectorScorer())"
1944+
+ ")";
19351945
assertEquals(expectedString, knnVectorsFormat.toString());
19361946
}
19371947

@@ -2061,14 +2071,23 @@ public void testKnnBBQHNSWVectorsFormat() throws IOException {
20612071
assertThat(codec, instanceOf(LegacyPerFieldMapperCodec.class));
20622072
knnVectorsFormat = ((LegacyPerFieldMapperCodec) codec).getKnnVectorsFormatForField("field");
20632073
}
2064-
String expectedString = "ES93HnswBinaryQuantizedVectorsFormat(name=ES93HnswBinaryQuantizedVectorsFormat, maxConn="
2074+
String expectedString = ES93GenericFlatVectorsFormat.GENERIC_VECTOR_FORMAT.isEnabled()
2075+
? "ES93HnswBinaryQuantizedVectorsFormat(name=ES93HnswBinaryQuantizedVectorsFormat, maxConn="
20652076
+ m
20662077
+ ", beamWidth="
20672078
+ efConstruction
20682079
+ ", flatVectorFormat=ES93BinaryQuantizedVectorsFormat("
20692080
+ "name=ES93BinaryQuantizedVectorsFormat, "
20702081
+ "rawVectorFormat=ES93GenericFlatVectorsFormat(name=ES93GenericFlatVectorsFormat,"
2071-
+ " format=Lucene99FlatVectorsFormat";
2082+
+ " format=Lucene99FlatVectorsFormat"
2083+
: "ES818HnswBinaryQuantizedVectorsFormat(name=ES818HnswBinaryQuantizedVectorsFormat, maxConn="
2084+
+ m
2085+
+ ", beamWidth="
2086+
+ efConstruction
2087+
+ ", flatVectorFormat=ES818BinaryQuantizedVectorsFormat("
2088+
+ "name=ES818BinaryQuantizedVectorsFormat, "
2089+
+ "flatVectorScorer=ES818BinaryFlatVectorsScorer(nonQuantizedDelegate=DefaultFlatVectorScorer())))";
2090+
assertEquals(expectedString, knnVectorsFormat.toString());;
20722091
assertThat(knnVectorsFormat, hasToString(startsWith(expectedString)));
20732092
}
20742093

@@ -2199,7 +2218,9 @@ protected boolean supportsEmptyInputArray() {
21992218

22002219
private static class DenseVectorSyntheticSourceSupport implements SyntheticSourceSupport {
22012220
private final int dims = between(5, 1000);
2202-
private final ElementType elementType = randomFrom(ElementType.BYTE, ElementType.FLOAT, ElementType.BFLOAT16, ElementType.BIT);
2221+
private final ElementType elementType = ES93GenericFlatVectorsFormat.GENERIC_VECTOR_FORMAT.isEnabled()
2222+
? randomFrom(ElementType.BYTE, ElementType.FLOAT, ElementType.BFLOAT16, ElementType.BIT)
2223+
: randomFrom(ElementType.BYTE, ElementType.FLOAT, ElementType.BIT);
22032224
private final boolean indexed = randomBoolean();
22042225
private final boolean indexOptionsSet = indexed && randomBoolean();
22052226

0 commit comments

Comments
 (0)