Skip to content

Commit b5707ae

Browse files
committed
test(qdrant): add test to verify Long metadata values are stored as String
Adds a test to ensure that Long values in document metadata are safely converted to String before being stored in Qdrant. The test inserts a document with a Long-type "ref_id", performs a similarity search, and verifies that: - the result is not empty, - the retrieved "ref_id" is a String, - the value matches the original Long when parsed. Also ensures cleanup by deleting the inserted document from the store.
1 parent 46223b9 commit b5707ae

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,27 @@ void getNativeClientTest() {
314314
});
315315
}
316316

317+
@Test
318+
void shouldConvertLongToString() {
319+
this.contextRunner.run(context -> {
320+
QdrantVectorStore vectorStore = context.getBean(QdrantVectorStore.class);
321+
var refId = System.currentTimeMillis();
322+
var doc = new Document("Long type ref_id", Map.of("ref_id", refId));
323+
vectorStore.add(List.of(doc));
324+
325+
List<Document> results = vectorStore
326+
.similaritySearch(SearchRequest.builder().query("Long type ref_id").topK(1).build());
327+
assertThat(results).hasSize(1);
328+
Document resultDoc = results.get(0);
329+
var resultRefId = resultDoc.getMetadata().get("ref_id");
330+
assertThat(resultRefId).isInstanceOf(String.class);
331+
assertThat(Double.valueOf((String) resultRefId)).isEqualTo(refId);
332+
333+
// Remove all documents from the store
334+
vectorStore.delete(List.of(resultDoc.getId()));
335+
});
336+
}
337+
317338
@SpringBootConfiguration
318339
public static class TestApplication {
319340

0 commit comments

Comments
 (0)