diff --git a/vector-stores/spring-ai-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant/QdrantValueFactory.java b/vector-stores/spring-ai-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant/QdrantValueFactory.java index b328f418985..c062e1f6cae 100644 --- a/vector-stores/spring-ai-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant/QdrantValueFactory.java +++ b/vector-stores/spring-ai-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant/QdrantValueFactory.java @@ -75,6 +75,9 @@ private static Value value(Object value) { return ValueFactory.value((String) value); case "Integer": return ValueFactory.value((Integer) value); + case "Long": + // use String representation + return ValueFactory.value(String.valueOf(value)); case "Double": return ValueFactory.value((Double) value); case "Float": diff --git a/vector-stores/spring-ai-qdrant-store/src/test/java/org/springframework/ai/vectorstore/qdrant/QdrantVectorStoreIT.java b/vector-stores/spring-ai-qdrant-store/src/test/java/org/springframework/ai/vectorstore/qdrant/QdrantVectorStoreIT.java index 004bf32d226..b2af2ab758c 100644 --- a/vector-stores/spring-ai-qdrant-store/src/test/java/org/springframework/ai/vectorstore/qdrant/QdrantVectorStoreIT.java +++ b/vector-stores/spring-ai-qdrant-store/src/test/java/org/springframework/ai/vectorstore/qdrant/QdrantVectorStoreIT.java @@ -314,6 +314,27 @@ void getNativeClientTest() { }); } + @Test + void shouldConvertLongToString() { + this.contextRunner.run(context -> { + QdrantVectorStore vectorStore = context.getBean(QdrantVectorStore.class); + var refId = System.currentTimeMillis(); + var doc = new Document("Long type ref_id", Map.of("ref_id", refId)); + vectorStore.add(List.of(doc)); + + List results = vectorStore + .similaritySearch(SearchRequest.builder().query("Long type ref_id").topK(1).build()); + assertThat(results).hasSize(1); + Document resultDoc = results.get(0); + var resultRefId = resultDoc.getMetadata().get("ref_id"); + assertThat(resultRefId).isInstanceOf(String.class); + assertThat(Double.valueOf((String) resultRefId)).isEqualTo(refId); + + // Remove all documents from the store + vectorStore.delete(List.of(resultDoc.getId())); + }); + } + @SpringBootConfiguration public static class TestApplication {