Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ public static DenseVectorFieldMapper.DenseVectorIndexOptions randomGpuSupportedI
}

public static DenseVectorFieldMapper.VectorSimilarity randomGPUSupportedSimilarity(
DenseVectorFieldMapper.DenseVectorIndexOptions indexOptions
DenseVectorFieldMapper.VectorIndexType vectorIndexType
) {
if (indexOptions.getType() == DenseVectorFieldMapper.VectorIndexType.INT8_HNSW) {
if (vectorIndexType == DenseVectorFieldMapper.VectorIndexType.INT8_HNSW) {
return randomFrom(VectorSimilarity.L2_NORM, VectorSimilarity.COSINE, VectorSimilarity.DOT_PRODUCT);
}
return randomFrom(VectorSimilarity.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void testFFOffGPUFormatNull() {
var format = vectorsFormatProvider.getKnnVectorsFormat(
settings,
indexOptions,
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions)
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions.getType())
);
assertNull(format);
}
Expand All @@ -158,7 +158,7 @@ public void testIndexSettingOnIndexTypeSupportedGPUSupported() {
var format = vectorsFormatProvider.getKnnVectorsFormat(
settings,
indexOptions,
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions)
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions.getType())
);
assertNotNull(format);
}
Expand All @@ -179,7 +179,7 @@ public void testIndexSettingOnIndexTypeNotSupportedThrows() {
() -> vectorsFormatProvider.getKnnVectorsFormat(
settings,
indexOptions,
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions)
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions.getType())
)
);
assertThat(ex.getMessage(), startsWith("[index.vectors.indexing.use_gpu] doesn't support [index_options.type] of"));
Expand All @@ -201,7 +201,7 @@ public void testIndexSettingOnGPUNotSupportedThrows() {
() -> vectorsFormatProvider.getKnnVectorsFormat(
settings,
indexOptions,
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions)
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions.getType())
)
);
assertThat(
Expand All @@ -227,7 +227,7 @@ public void testIndexSettingOnGPUSupportThrowsRethrows() {
() -> vectorsFormatProvider.getKnnVectorsFormat(
settings,
indexOptions,
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions)
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions.getType())
)
);
assertThat(
Expand All @@ -250,7 +250,7 @@ public void testIndexSettingAutoIndexTypeSupportedGPUSupported() {
var format = vectorsFormatProvider.getKnnVectorsFormat(
settings,
indexOptions,
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions)
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions.getType())
);
assertNotNull(format);
}
Expand All @@ -269,7 +269,7 @@ public void testIndexSettingAutoGPUNotSupported() {
var format = vectorsFormatProvider.getKnnVectorsFormat(
settings,
indexOptions,
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions)
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions.getType())
);
assertNull(format);
}
Expand All @@ -288,7 +288,7 @@ public void testIndexSettingAutoIndexTypeNotSupported() {
var format = vectorsFormatProvider.getKnnVectorsFormat(
settings,
indexOptions,
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions)
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions.getType())
);
assertNull(format);
}
Expand All @@ -307,7 +307,7 @@ public void testIndexSettingOff() {
var format = vectorsFormatProvider.getKnnVectorsFormat(
settings,
indexOptions,
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions)
DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(indexOptions.getType())
);
assertNull(format);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import org.apache.lucene.tests.util.LuceneTestCase;
import org.apache.lucene.tests.util.TestUtil;
import org.elasticsearch.common.logging.LogConfigurator;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldTypeTests;
import org.elasticsearch.xpack.gpu.GPUSupport;
import org.junit.BeforeClass;

Expand All @@ -39,7 +42,8 @@ protected Codec getCodec() {

@Override
protected VectorSimilarityFunction randomSimilarity() {
return VectorSimilarityFunction.values()[random().nextInt(VectorSimilarityFunction.values().length)];
return DenseVectorFieldTypeTests.randomGPUSupportedSimilarity(DenseVectorFieldMapper.VectorIndexType.INT8_HNSW)
.vectorSimilarityFunction(IndexVersion.current(), DenseVectorFieldMapper.ElementType.FLOAT);
}

@Override
Expand Down