Skip to content

Commit 48fb663

Browse files
Fix qdrant vector store value factory (#3173)
- Fix the QdrantValueFactory to handle "java.util.List" type - Update the integration test to use List type values Resolves #3164 Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
1 parent add7ca8 commit 48fb663

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

vector-stores/spring-ai-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant/QdrantValueFactory.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* Utility methods for building io.qdrant.client.grpc.JsonWithInt.Value from Java objects.
3333
*
3434
* @author Anush Shetty
35+
* @author Ilayaperumal Gopinathan
3536
* @since 0.8.1
3637
*/
3738
final class QdrantValueFactory {
@@ -65,6 +66,10 @@ private static Value value(Object value) {
6566
return value((Map<String, Object>) value);
6667
}
6768

69+
if (value instanceof List) {
70+
return value((List<Object>) value);
71+
}
72+
6873
switch (value.getClass().getSimpleName()) {
6974
case "String":
7075
return ValueFactory.value((String) value);
@@ -81,6 +86,16 @@ private static Value value(Object value) {
8186
}
8287
}
8388

89+
private static Value value(List<Object> elements) {
90+
List<Value> values = new ArrayList<Value>(elements.size());
91+
92+
for (Object element : elements) {
93+
values.add(value(element));
94+
}
95+
96+
return ValueFactory.list(values);
97+
}
98+
8499
private static Value value(Object[] elements) {
85100
List<Value> values = new ArrayList<Value>(elements.length);
86101

vector-stores/spring-ai-qdrant-store/src/test/java/org/springframework/ai/vectorstore/qdrant/QdrantVectorStoreIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ public class QdrantVectorStoreIT extends BaseVectorStoreTests {
7979
List<Document> documents = List.of(
8080
new Document("Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!!",
8181
Collections.singletonMap("meta1", "meta1")),
82-
new Document("Hello World Hello World Hello World Hello World Hello World Hello World Hello World"),
82+
new Document("Hello World Hello World Hello World Hello World Hello World Hello World Hello World",
83+
Collections.singletonMap("meta1", List.of("meta-list"))),
8384
new Document(
8485
"Great Depression Great Depression Great Depression Great Depression Great Depression Great Depression",
85-
Collections.singletonMap("meta2", "meta2")));
86+
Collections.singletonMap("meta2", List.of("meta-list"))));
8687

8788
@BeforeAll
8889
static void setup() throws InterruptedException, ExecutionException {

0 commit comments

Comments
 (0)