mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-13 23:52:10 +00:00
Fix similarity field mapping.
Original Pull Request #2666 Closes #2659 (cherry picked from commit 8c5ff92cd2ec2177452dc0aa1b9307bdfcfa4e75) (cherry picked from commit 9b9136d852d61c3bcdb429ec648b1e08272e017f) # Conflicts: # src/main/java/org/springframework/data/elasticsearch/core/index/MappingParameters.java # src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java
This commit is contained in:
parent
19ec05dae3
commit
ec8401a2fb
@ -332,6 +332,8 @@ public final class MappingParameters {
|
|||||||
|
|
||||||
if (similarity != Similarity.Default) {
|
if (similarity != Similarity.Default) {
|
||||||
objectNode.put(FIELD_PARAM_SIMILARITY, similarity.toString());
|
objectNode.put(FIELD_PARAM_SIMILARITY, similarity.toString());
|
||||||
|
// similarity must have index explicitly set, otherwise Elasticsearch returns an error
|
||||||
|
objectNode.put(FIELD_PARAM_INDEX, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (termVector != TermVector.none) {
|
if (termVector != TermVector.none) {
|
||||||
|
@ -279,6 +279,12 @@ public abstract class MappingBuilderIntegrationTests extends MappingContextBaseT
|
|||||||
indexOps.createWithMapping();
|
indexOps.createWithMapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // #2659
|
||||||
|
@DisplayName("should write correct mapping for dense vector property")
|
||||||
|
void shouldWriteCorrectMappingForDenseVectorProperty() {
|
||||||
|
operations.indexOps(SimilarityEntity.class).createWithMapping();
|
||||||
|
}
|
||||||
|
|
||||||
// region Entities
|
// region Entities
|
||||||
@Document(indexName = "#{@indexNameProvider.indexName()}")
|
@Document(indexName = "#{@indexNameProvider.indexName()}")
|
||||||
static class Book {
|
static class Book {
|
||||||
@ -901,5 +907,14 @@ public abstract class MappingBuilderIntegrationTests extends MappingContextBaseT
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Field(type = FieldType.Dense_Vector, dims = 1) String denseVectorField;
|
@Field(type = FieldType.Dense_Vector, dims = 1) String denseVectorField;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Document(indexName = "#{@indexNameProvider.indexName()}")
|
||||||
|
static class SimilarityEntity {
|
||||||
|
@Nullable
|
||||||
|
@Id private String id;
|
||||||
|
|
||||||
|
@Field(type = FieldType.Dense_Vector, dims = 42, similarity = "cosine") private double[] denseVector;
|
||||||
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user