Skip to content

Commit 8f3be15

Browse files
author
Milder Hernandez Cagua
committed
Add distance function to custom definitions
1 parent b86c641 commit 8f3be15

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/connectors/memory/redis/RedisHashSetVectorStoreRecordCollectionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ private static Stream<Arguments> provideSearchParameters() {
344344
@ParameterizedTest
345345
@MethodSource("provideSearchParameters")
346346
public void search(RecordCollectionOptions options, String embeddingName) {
347-
String collectionName = "search" + embeddingName;
347+
String collectionName = "search" + options.name() + embeddingName;
348348
RedisHashSetVectorStoreRecordCollection<Hotel> recordCollection = buildRecordCollection(optionsMap.get(options), collectionName);
349349

350350
List<Hotel> hotels = getHotels();
@@ -366,7 +366,7 @@ public void search(RecordCollectionOptions options, String embeddingName) {
366366
@ParameterizedTest
367367
@MethodSource("provideSearchParameters")
368368
public void searchWithVectors(RecordCollectionOptions options, String embeddingName) {
369-
String collectionName = "search" + embeddingName;
369+
String collectionName = "search" + options.name() + embeddingName;
370370
RedisHashSetVectorStoreRecordCollection<Hotel> recordCollection = buildRecordCollection(optionsMap.get(options), collectionName);
371371

372372
List<Hotel> hotels = getHotels();
@@ -389,7 +389,7 @@ public void searchWithVectors(RecordCollectionOptions options, String embeddingN
389389
@ParameterizedTest
390390
@MethodSource("provideSearchParameters")
391391
public void searchWithOffSet(RecordCollectionOptions options, String embeddingName) {
392-
String collectionName = "search" + embeddingName;
392+
String collectionName = "search" + options.name() + embeddingName;
393393
RedisHashSetVectorStoreRecordCollection<Hotel> recordCollection = buildRecordCollection(optionsMap.get(options), collectionName);
394394

395395
List<Hotel> hotels = getHotels();

api-test/integration-tests/src/test/java/com/microsoft/semantickernel/tests/connectors/memory/redis/RedisJsonVectorStoreRecordCollectionTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.microsoft.semantickernel.connectors.data.redis.RedisJsonVectorStoreRecordCollection;
44
import com.microsoft.semantickernel.connectors.data.redis.RedisJsonVectorStoreRecordCollectionOptions;
55
import com.microsoft.semantickernel.data.vectorsearch.VectorSearchResult;
6+
import com.microsoft.semantickernel.data.vectorstorage.definition.DistanceFunction;
67
import com.microsoft.semantickernel.data.vectorstorage.definition.VectorStoreRecordDataField;
78
import com.microsoft.semantickernel.data.vectorstorage.definition.VectorStoreRecordDefinition;
89
import com.microsoft.semantickernel.data.vectorstorage.definition.VectorStoreRecordField;
@@ -75,18 +76,21 @@ static void setup() {
7576
fields.add(VectorStoreRecordVectorField.builder()
7677
.withName("euclidean")
7778
.withStorageName("summaryEmbedding1")
79+
.withDistanceFunction(DistanceFunction.EUCLIDEAN_DISTANCE)
7880
.withFieldType(List.class)
7981
.withDimensions(8)
8082
.build());
8183
fields.add(VectorStoreRecordVectorField.builder()
8284
.withName("cosineDistance")
8385
.withStorageName("summaryEmbedding2")
86+
.withDistanceFunction(DistanceFunction.COSINE_DISTANCE)
8487
.withFieldType(List.class)
8588
.withDimensions(8)
8689
.build());
8790
fields.add(VectorStoreRecordVectorField.builder()
8891
.withName("dotProduct")
8992
.withStorageName("summaryEmbedding3")
93+
.withDistanceFunction(DistanceFunction.DOT_PRODUCT)
9094
.withFieldType(List.class)
9195
.withDimensions(8)
9296
.build());
@@ -343,7 +347,7 @@ private static Stream<Arguments> provideSearchParameters() {
343347
@ParameterizedTest
344348
@MethodSource("provideSearchParameters")
345349
public void search(RecordCollectionOptions options, String embeddingName) {
346-
String collectionName = "search" + embeddingName;
350+
String collectionName = "search" + options.name() + embeddingName;
347351
RedisJsonVectorStoreRecordCollection<Hotel> recordCollection = buildRecordCollection(optionsMap.get(options), collectionName);
348352

349353
List<Hotel> hotels = getHotels();
@@ -365,7 +369,7 @@ public void search(RecordCollectionOptions options, String embeddingName) {
365369
@ParameterizedTest
366370
@MethodSource("provideSearchParameters")
367371
public void searchWithVectors(RecordCollectionOptions options, String embeddingName) {
368-
String collectionName = "search" + embeddingName;
372+
String collectionName = "search" + options.name() + embeddingName;
369373
RedisJsonVectorStoreRecordCollection<Hotel> recordCollection = buildRecordCollection(optionsMap.get(options), collectionName);
370374

371375
List<Hotel> hotels = getHotels();
@@ -388,7 +392,7 @@ public void searchWithVectors(RecordCollectionOptions options, String embeddingN
388392
@ParameterizedTest
389393
@MethodSource("provideSearchParameters")
390394
public void searchWithOffSet(RecordCollectionOptions options, String embeddingName) {
391-
String collectionName = "search" + embeddingName;
395+
String collectionName = "search" + options.name() + embeddingName;
392396
RedisJsonVectorStoreRecordCollection<Hotel> recordCollection = buildRecordCollection(optionsMap.get(options), collectionName);
393397

394398
List<Hotel> hotels = getHotels();

0 commit comments

Comments
 (0)