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>
This commit is contained in:
Ilayaperumal Gopinathan
2025-05-15 16:26:23 +01:00
committed by GitHub
parent add7ca8489
commit 48fb663c31
2 changed files with 18 additions and 2 deletions

View File

@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
* Utility methods for building io.qdrant.client.grpc.JsonWithInt.Value from Java objects.
*
* @author Anush Shetty
* @author Ilayaperumal Gopinathan
* @since 0.8.1
*/
final class QdrantValueFactory {
@@ -65,6 +66,10 @@ final class QdrantValueFactory {
return value((Map<String, Object>) value);
}
if (value instanceof List) {
return value((List<Object>) value);
}
switch (value.getClass().getSimpleName()) {
case "String":
return ValueFactory.value((String) value);
@@ -81,6 +86,16 @@ final class QdrantValueFactory {
}
}
private static Value value(List<Object> elements) {
List<Value> values = new ArrayList<Value>(elements.size());
for (Object element : elements) {
values.add(value(element));
}
return ValueFactory.list(values);
}
private static Value value(Object[] elements) {
List<Value> values = new ArrayList<Value>(elements.length);

View File

@@ -79,10 +79,11 @@ public class QdrantVectorStoreIT extends BaseVectorStoreTests {
List<Document> documents = List.of(
new Document("Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!!",
Collections.singletonMap("meta1", "meta1")),
new Document("Hello World Hello World Hello World Hello World Hello World Hello World Hello World"),
new Document("Hello World Hello World Hello World Hello World Hello World Hello World Hello World",
Collections.singletonMap("meta1", List.of("meta-list"))),
new Document(
"Great Depression Great Depression Great Depression Great Depression Great Depression Great Depression",
Collections.singletonMap("meta2", "meta2")));
Collections.singletonMap("meta2", List.of("meta-list"))));
@BeforeAll
static void setup() throws InterruptedException, ExecutionException {