| 
47 | 47 | import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.ElementType;  | 
48 | 48 | import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.VectorSimilarity;  | 
49 | 49 | import org.elasticsearch.index.query.SearchExecutionContext;  | 
 | 50 | +import org.elasticsearch.nativeaccess.NativeAccess;  | 
50 | 51 | import org.elasticsearch.search.lookup.Source;  | 
51 | 52 | import org.elasticsearch.search.lookup.SourceProvider;  | 
52 | 53 | import org.elasticsearch.search.vectors.VectorData;  | 
@@ -2621,6 +2622,8 @@ public void testFloatVectorQueryBoundaries() throws IOException {  | 
2621 | 2622 |         );  | 
2622 | 2623 |     }  | 
2623 | 2624 | 
 
  | 
 | 2625 | +    static final boolean optimizedScorer = NativeAccess.instance().getVectorSimilarityFunctions().isPresent();  | 
 | 2626 | + | 
2624 | 2627 |     public void testKnnVectorsFormat() throws IOException {  | 
2625 | 2628 |         final int m = randomIntBetween(1, DEFAULT_MAX_CONN + 10);  | 
2626 | 2629 |         final int efConstruction = randomIntBetween(1, DEFAULT_BEAM_WIDTH + 10);  | 
@@ -2654,11 +2657,14 @@ public void testKnnVectorsFormat() throws IOException {  | 
2654 | 2657 |             assertThat(codec, instanceOf(LegacyPerFieldMapperCodec.class));  | 
2655 | 2658 |             knnVectorsFormat = ((LegacyPerFieldMapperCodec) codec).getKnnVectorsFormatForField("field");  | 
2656 | 2659 |         }  | 
2657 |  | -        String expectedString = "Lucene99HnswVectorsFormat(name=Lucene99HnswVectorsFormat, maxConn="  | 
 | 2660 | +        var expectedScorer = optimizedScorer  | 
 | 2661 | +            ? "ESFlatVectorsScorer(delegate=DefaultFlatVectorScorer(), factory=VectorScorerFactoryImpl)"  | 
 | 2662 | +            : "DefaultFlatVectorScorer()";  | 
 | 2663 | +        String expectedString = "ES819HnswVectorsFormat(name=ES819HnswVectorsFormat, maxConn="  | 
2658 | 2664 |             + (setM ? m : DEFAULT_MAX_CONN)  | 
2659 | 2665 |             + ", beamWidth="  | 
2660 | 2666 |             + (setEfConstruction ? efConstruction : DEFAULT_BEAM_WIDTH)  | 
2661 |  | -            + ", flatVectorFormat=Lucene99FlatVectorsFormat(vectorsScorer=DefaultFlatVectorScorer())"  | 
 | 2667 | +            + ", flatVectorFormat=Lucene99FlatVectorsFormat(vectorsScorer=%scorer%)".replace("%scorer%", expectedScorer)  | 
2662 | 2668 |             + ")";  | 
2663 | 2669 |         assertEquals(expectedString, knnVectorsFormat.toString());  | 
2664 | 2670 |     }  | 
 | 
0 commit comments