-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from milderhc/redis-vector-search
Add vector search for Redis JSON and HashSet
- Loading branch information
Showing
20 changed files
with
969 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...tests/src/test/java/com/microsoft/semantickernel/tests/connectors/memory/redis/Hotel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.microsoft.semantickernel.tests.connectors.memory.redis; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.microsoft.semantickernel.data.vectorstorage.attributes.VectorStoreRecordDataAttribute; | ||
import com.microsoft.semantickernel.data.vectorstorage.attributes.VectorStoreRecordKeyAttribute; | ||
import com.microsoft.semantickernel.data.vectorstorage.attributes.VectorStoreRecordVectorAttribute; | ||
|
||
import java.util.List; | ||
|
||
public class Hotel { | ||
@VectorStoreRecordKeyAttribute | ||
private final String id; | ||
|
||
@VectorStoreRecordDataAttribute(isFilterable = true) | ||
private final String name; | ||
|
||
@VectorStoreRecordDataAttribute | ||
private final int code; | ||
|
||
@JsonProperty("summary") | ||
@VectorStoreRecordDataAttribute() | ||
private final String description; | ||
|
||
@JsonProperty("summaryEmbedding1") | ||
@VectorStoreRecordVectorAttribute(dimensions = 8, distanceFunction = "euclidean") | ||
private final List<Float> euclidean; | ||
|
||
@JsonProperty("summaryEmbedding2") | ||
@VectorStoreRecordVectorAttribute(dimensions = 8, distanceFunction = "cosineDistance") | ||
private final List<Float> cosineDistance; | ||
|
||
@JsonProperty("summaryEmbedding3") | ||
@VectorStoreRecordVectorAttribute(dimensions = 8, distanceFunction = "dotProduct") | ||
private final List<Float> dotProduct; | ||
@VectorStoreRecordDataAttribute | ||
private double rating; | ||
|
||
public Hotel() { | ||
this(null, null, 0, null, null, null, null, 0.0); | ||
} | ||
|
||
@JsonCreator | ||
public Hotel( | ||
@JsonProperty("id") String id, | ||
@JsonProperty("name") String name, | ||
@JsonProperty("code") int code, | ||
@JsonProperty("summary") String description, | ||
@JsonProperty("summaryEmbedding1") List<Float> euclidean, | ||
@JsonProperty("summaryEmbedding2") List<Float> cosineDistance, | ||
@JsonProperty("summaryEmbedding3") List<Float> dotProduct, | ||
@JsonProperty("rating") double rating) { | ||
this.id = id; | ||
this.name = name; | ||
this.code = code; | ||
this.description = description; | ||
this.euclidean = euclidean; | ||
this.cosineDistance = euclidean; | ||
this.dotProduct = euclidean; | ||
this.rating = rating; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public int getCode() { | ||
return code; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public List<Float> getEuclidean() { | ||
return euclidean; | ||
} | ||
|
||
public List<Float> getCosineDistance() { | ||
return cosineDistance; | ||
} | ||
|
||
public List<Float> getDotProduct() { | ||
return dotProduct; | ||
} | ||
|
||
public double getRating() { | ||
return rating; | ||
} | ||
|
||
public void setRating(double rating) { | ||
this.rating = rating; | ||
} | ||
} |
178 changes: 146 additions & 32 deletions
178
...ntickernel/tests/connectors/memory/redis/RedisHashSetVectorStoreRecordCollectionTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
179 changes: 146 additions & 33 deletions
179
...emantickernel/tests/connectors/memory/redis/RedisJsonVectorStoreRecordCollectionTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.