Fix missing element_type when using elasticsearch-java 8.14.x

Original Pull Request #2928
Closes #2927
This commit is contained in:
puppylpg 2024-06-13 00:27:43 +08:00 committed by GitHub
parent d101eebc6d
commit d9d1b73dad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -29,6 +29,7 @@ import org.springframework.data.annotation.Id;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldElementType;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.KnnAlgorithmType; import org.springframework.data.elasticsearch.annotations.KnnAlgorithmType;
import org.springframework.data.elasticsearch.annotations.KnnIndexOptions; import org.springframework.data.elasticsearch.annotations.KnnIndexOptions;
@ -142,12 +143,7 @@ public abstract class KnnSearchIntegrationTests {
@Nullable @Nullable
@Field(type = Keyword) private String message; @Field(type = Keyword) private String message;
// TODO: `elementType = FieldElementType.FLOAT,` is to be added here later @Field(type = FieldType.Dense_Vector, dims = 2, elementType = FieldElementType.FLOAT,
// TODO: element_type can not be set here, because it's left out in elasticsearch-specification
// TODO: the issue is fixed in https://github.com/elastic/elasticsearch-java/pull/800, but still not released in
// 8.13.x
// TODO: will be fixed later by either upgrading to 8.14.0 or a newer 8.13.x
@Field(type = FieldType.Dense_Vector, dims = 2,
knnIndexOptions = @KnnIndexOptions(type = KnnAlgorithmType.HNSW, m = 16, efConstruction = 100), knnIndexOptions = @KnnIndexOptions(type = KnnAlgorithmType.HNSW, m = 16, efConstruction = 100),
knnSimilarity = KnnSimilarity.COSINE) private float[] vector; knnSimilarity = KnnSimilarity.COSINE) private float[] vector;