|
34 | 34 | import org.elasticsearch.index.codec.PerFieldMapperCodec; |
35 | 35 | import org.elasticsearch.index.codec.vectors.BFloat16; |
36 | 36 | import org.elasticsearch.index.codec.vectors.diskbbq.ES920DiskBBQVectorsFormat; |
| 37 | +import org.elasticsearch.index.codec.vectors.es93.ES93GenericFlatVectorsFormat; |
37 | 38 | import org.elasticsearch.index.mapper.DocumentMapper; |
38 | 39 | import org.elasticsearch.index.mapper.DocumentParsingException; |
39 | 40 | import org.elasticsearch.index.mapper.FieldMapper; |
@@ -90,7 +91,9 @@ public class DenseVectorFieldMapperTests extends SyntheticVectorsMapperTestCase |
90 | 91 | private final int dims; |
91 | 92 |
|
92 | 93 | 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); |
94 | 97 | this.indexed = usually(); |
95 | 98 | this.indexOptionsSet = this.indexed && randomBoolean(); |
96 | 99 | int baseDims = ElementType.BIT == elementType ? 4 * Byte.SIZE : 4; |
@@ -1926,12 +1929,19 @@ public void testKnnVectorsFormat() throws IOException { |
1926 | 1929 | assertThat(codec, instanceOf(LegacyPerFieldMapperCodec.class)); |
1927 | 1930 | knnVectorsFormat = ((LegacyPerFieldMapperCodec) codec).getKnnVectorsFormatForField("field"); |
1928 | 1931 | } |
1929 | | - String expectedString = "ES93HnswVectorsFormat(name=ES93HnswVectorsFormat, maxConn=" |
| 1932 | + String expectedString = ES93GenericFlatVectorsFormat.GENERIC_VECTOR_FORMAT.isEnabled() |
| 1933 | + ? "ES93HnswVectorsFormat(name=ES93HnswVectorsFormat, maxConn=" |
1930 | 1934 | + (setM ? m : DEFAULT_MAX_CONN) |
1931 | 1935 | + ", beamWidth=" |
1932 | 1936 | + (setEfConstruction ? efConstruction : DEFAULT_BEAM_WIDTH) |
1933 | 1937 | + ", 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 | + + ")"; |
1935 | 1945 | assertEquals(expectedString, knnVectorsFormat.toString()); |
1936 | 1946 | } |
1937 | 1947 |
|
@@ -2061,14 +2071,23 @@ public void testKnnBBQHNSWVectorsFormat() throws IOException { |
2061 | 2071 | assertThat(codec, instanceOf(LegacyPerFieldMapperCodec.class)); |
2062 | 2072 | knnVectorsFormat = ((LegacyPerFieldMapperCodec) codec).getKnnVectorsFormatForField("field"); |
2063 | 2073 | } |
2064 | | - String expectedString = "ES93HnswBinaryQuantizedVectorsFormat(name=ES93HnswBinaryQuantizedVectorsFormat, maxConn=" |
| 2074 | + String expectedString = ES93GenericFlatVectorsFormat.GENERIC_VECTOR_FORMAT.isEnabled() |
| 2075 | + ? "ES93HnswBinaryQuantizedVectorsFormat(name=ES93HnswBinaryQuantizedVectorsFormat, maxConn=" |
2065 | 2076 | + m |
2066 | 2077 | + ", beamWidth=" |
2067 | 2078 | + efConstruction |
2068 | 2079 | + ", flatVectorFormat=ES93BinaryQuantizedVectorsFormat(" |
2069 | 2080 | + "name=ES93BinaryQuantizedVectorsFormat, " |
2070 | 2081 | + "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());; |
2072 | 2091 | assertThat(knnVectorsFormat, hasToString(startsWith(expectedString))); |
2073 | 2092 | } |
2074 | 2093 |
|
@@ -2199,7 +2218,9 @@ protected boolean supportsEmptyInputArray() { |
2199 | 2218 |
|
2200 | 2219 | private static class DenseVectorSyntheticSourceSupport implements SyntheticSourceSupport { |
2201 | 2220 | 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); |
2203 | 2224 | private final boolean indexed = randomBoolean(); |
2204 | 2225 | private final boolean indexOptionsSet = indexed && randomBoolean(); |
2205 | 2226 |
|
|
0 commit comments