Skip to content

Commit fade919

Browse files
committed
Polishing.
1 parent 687b014 commit fade919

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,7 @@ static class SimilarityEntity {
909909
@Nullable
910910
@Id private String id;
911911

912-
@Field(type = FieldType.Dense_Vector, dims = 42, knnSimilarity = KnnSimilarity.COSINE)
913-
private double[] denseVector;
912+
@Field(type = FieldType.Dense_Vector, dims = 42, knnSimilarity = KnnSimilarity.COSINE) private double[] denseVector;
914913
}
915914

916915
@Mapping(aliases = {

src/test/java/org/springframework/data/elasticsearch/repositories/knn/KnnSearchIntegrationTests.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
import org.springframework.beans.factory.annotation.Autowired;
2828
import org.springframework.data.annotation.Id;
2929
import org.springframework.data.domain.Pageable;
30-
import org.springframework.data.elasticsearch.annotations.*;
30+
import org.springframework.data.elasticsearch.annotations.Document;
31+
import org.springframework.data.elasticsearch.annotations.Field;
32+
import org.springframework.data.elasticsearch.annotations.FieldType;
33+
import org.springframework.data.elasticsearch.annotations.KnnAlgorithmType;
34+
import org.springframework.data.elasticsearch.annotations.KnnIndexOptions;
35+
import org.springframework.data.elasticsearch.annotations.KnnSimilarity;
3136
import org.springframework.data.elasticsearch.client.elc.NativeQuery;
3237
import org.springframework.data.elasticsearch.client.elc.NativeQueryBuilder;
3338
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
@@ -71,7 +76,7 @@ private List<VectorEntity> createVectorEntities(int n) {
7176
entity.setMessage("top" + (i + 1));
7277

7378
// The generated vector is always in the first quadrant, from the x-axis direction to the y-axis direction
74-
float[] vector = new float[] {1.0f - i * increment, increment};
79+
float[] vector = new float[] { 1.0f - i * increment, increment };
7580
entity.setVector(vector);
7681
entities.add(entity);
7782
}
@@ -127,27 +132,24 @@ public void shouldReturnYAxisVector() {
127132
assertThat(vectorEntities.get(0).getMessage()).isEqualTo("top10");
128133
}
129134

130-
public interface VectorEntityRepository extends ElasticsearchRepository<VectorEntity, String> {
131-
}
135+
public interface VectorEntityRepository extends ElasticsearchRepository<VectorEntity, String> {}
132136

133137
@Document(indexName = "#{@indexNameProvider.indexName()}")
134138
static class VectorEntity {
135139
@Nullable
136-
@Id
137-
private String id;
140+
@Id private String id;
138141

139142
@Nullable
140-
@Field(type = Keyword)
141-
private String message;
143+
@Field(type = Keyword) private String message;
142144

143145
// TODO: `elementType = FieldElementType.FLOAT,` is to be added here later
144146
// TODO: element_type can not be set here, because it's left out in elasticsearch-specification
145-
// TODO: the issue is fixed in https://github.com/elastic/elasticsearch-java/pull/800, but still not released in 8.13.x
147+
// TODO: the issue is fixed in https://github.com/elastic/elasticsearch-java/pull/800, but still not released in
148+
// 8.13.x
146149
// TODO: will be fixed later by either upgrading to 8.14.0 or a newer 8.13.x
147150
@Field(type = FieldType.Dense_Vector, dims = 2,
148151
knnIndexOptions = @KnnIndexOptions(type = KnnAlgorithmType.HNSW, m = 16, efConstruction = 100),
149-
knnSimilarity = KnnSimilarity.COSINE)
150-
private float[] vector;
152+
knnSimilarity = KnnSimilarity.COSINE) private float[] vector;
151153

152154
@Nullable
153155
public String getId() {

0 commit comments

Comments
 (0)