This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/main by this push:
     new 6e80b28bba Add test for QDrant similarity search
6e80b28bba is described below

commit 6e80b28bba5d04a058a1a49a45070ef555afc881
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Fri Feb 13 08:11:03 2026 +0100

    Add test for QDrant similarity search
    
    this is an important feature of Vector database, so even if there is
    allow chance that there is a specific difference with other features on
    Camel Quarkus side, remains good to cover it
    
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../component/qdrant/it/QdrantResource.java        | 66 ++++++++++++++++++++++
 .../quarkus/component/qdrant/it/QdrantTest.java    | 14 ++++-
 2 files changed, 78 insertions(+), 2 deletions(-)

diff --git 
a/integration-tests/qdrant/src/main/java/org/apache/camel/quarkus/component/qdrant/it/QdrantResource.java
 
b/integration-tests/qdrant/src/main/java/org/apache/camel/quarkus/component/qdrant/it/QdrantResource.java
index 6d08b06e9f..ad8f1f9a29 100644
--- 
a/integration-tests/qdrant/src/main/java/org/apache/camel/quarkus/component/qdrant/it/QdrantResource.java
+++ 
b/integration-tests/qdrant/src/main/java/org/apache/camel/quarkus/component/qdrant/it/QdrantResource.java
@@ -50,6 +50,37 @@ public class QdrantResource {
     @Inject
     FluentProducerTemplate producer;
 
+    // Enum to provide test data
+    public enum TestData {
+        VECTOR_1(9, "VECTOR_1", List.of(0.8f, 0.6f)),
+        VECTOR_2(10, "VECTOR_2", List.of(0.1f, 0.9f)),
+        VECTOR_3(11, "VECTOR_3", List.of(0.7f, 0.7f)),
+        VECTOR_4(12, "VECTOR_4", List.of(-0.3f, -0.9f)),
+        VECTOR_5(13, "VECTOR_5", List.of(1.2f, 0.8f));
+
+        private final int id;
+        private final String payload;
+        private final List<Float> vectors;
+
+        TestData(int id, String payload, List<Float> vectors) {
+            this.id = id;
+            this.payload = payload;
+            this.vectors = vectors;
+        }
+
+        public int getId() {
+            return id;
+        }
+
+        public List<Float> getVectors() {
+            return vectors;
+        }
+
+        public String getPayload() {
+            return payload;
+        }
+    }
+
     @Path("/createCollection")
     @PUT
     @Produces(MediaType.TEXT_PLAIN)
@@ -101,6 +132,41 @@ public class QdrantResource {
         return Response.ok(Integer.toString(retrieved.size()) + "/" + 
classes).build();
     }
 
+    @Path("/upsert-other-vectors")
+    @PUT
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response upsertOtherVectors() {
+        for (TestData testData : TestData.values()) {
+            producer.to("qdrant:testCollection")
+                    .withHeader(QdrantHeaders.ACTION, QdrantAction.UPSERT)
+                    .withBody(
+                            Points.PointStruct.newBuilder()
+                                    .setId(PointIdFactory.id(testData.getId()))
+                                    
.setVectors(VectorsFactory.vectors(testData.getVectors()))
+                                    .putPayload("text_segment", 
ValueFactory.value(testData.getPayload()))
+                                    .build())
+                    .request();
+        }
+        return Response.ok().build();
+    }
+
+    @Path("/similarity-search")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response similaritySearch() {
+
+        Exchange exchange = producer.to("qdrant:testCollection")
+                .withHeader(QdrantHeaders.ACTION, 
QdrantAction.SIMILARITY_SEARCH)
+                .withHeader(QdrantHeaders.INCLUDE_VECTORS, true)
+                .withHeader(QdrantHeaders.INCLUDE_PAYLOAD, true)
+                .withBody(List.of(0.75f, 0.65f))
+                .request(Exchange.class);
+
+        Collection<?> retrieved = exchange.getIn().getBody(Collection.class);
+        String classes = retrieved.stream().map(e -> 
e.getClass().getName()).distinct().collect(Collectors.joining("/"));
+        return Response.ok(Integer.toString(retrieved.size()) + "/" + 
classes).build();
+    }
+
     @Path("/delete")
     @DELETE
     @Produces(MediaType.TEXT_PLAIN)
diff --git 
a/integration-tests/qdrant/src/test/java/org/apache/camel/quarkus/component/qdrant/it/QdrantTest.java
 
b/integration-tests/qdrant/src/test/java/org/apache/camel/quarkus/component/qdrant/it/QdrantTest.java
index fc3a91958a..6862bf28e4 100644
--- 
a/integration-tests/qdrant/src/test/java/org/apache/camel/quarkus/component/qdrant/it/QdrantTest.java
+++ 
b/integration-tests/qdrant/src/test/java/org/apache/camel/quarkus/component/qdrant/it/QdrantTest.java
@@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.is;
 class QdrantTest {
 
     @Test
-    public void createUpsertRetrieveAndDeleteShouldSucceed() {
+    void createUpsertRetrieveAndDeleteShouldSucceed() {
         RestAssured.put("/qdrant/createCollection")
                 .then()
                 .statusCode(200);
@@ -42,10 +42,20 @@ class QdrantTest {
                 .statusCode(200)
                 .body(is("1/io.qdrant.client.grpc.Points$RetrievedPoint"));
 
+        // Inserting other vectors to have a good check on similarity search
+        RestAssured.put("/qdrant/upsert-other-vectors")
+                .then()
+                .statusCode(200);
+
+        RestAssured.get("/qdrant/similarity-search")
+                .then()
+                .statusCode(200)
+                .body(is("3/io.qdrant.client.grpc.Points$ScoredPoint"));
+
         RestAssured.delete("/qdrant/delete")
                 .then()
                 .statusCode(200)
-                .body(is("2/Completed/2"));
+                .body(is("7/Completed/2"));
 
         RestAssured.get("/qdrant/retrieve")
                 .then()

Reply via email to