You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2024/04/12 08:40:50 UTC
(camel) branch CAMEL-20574 created (now 3d46d10da2b)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch CAMEL-20574
in repository https://gitbox.apache.org/repos/asf/camel.git
at 3d46d10da2b CAMEL-20574 - Camel-Milvus: Add more producer operation - Query
This branch includes the following new commits:
new 3d46d10da2b CAMEL-20574 - Camel-Milvus: Add more producer operation - Query
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(camel) 01/01: CAMEL-20574 - Camel-Milvus: Add more producer operation - Query
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch CAMEL-20574
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3d46d10da2bda48bae78fa72aafa42a4702c265b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Apr 12 10:39:57 2024 +0200
CAMEL-20574 - Camel-Milvus: Add more producer operation - Query
Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
.../camel/component/milvus/MilvusAction.java | 1 +
.../camel/component/milvus/MilvusProducer.java | 18 +++++++++++++++++
.../component/milvus/it/MilvusComponentIT.java | 23 ++++++++++++++++++++++
3 files changed, 42 insertions(+)
diff --git a/components/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusAction.java b/components/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusAction.java
index 3ba9a290ac7..12650e81ea4 100644
--- a/components/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusAction.java
+++ b/components/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusAction.java
@@ -22,5 +22,6 @@ public enum MilvusAction {
UPSERT,
INSERT,
SEARCH,
+ QUERY,
DELETE
}
diff --git a/components/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusProducer.java b/components/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusProducer.java
index cf58965ca76..58be2861a53 100644
--- a/components/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusProducer.java
+++ b/components/camel-milvus/src/main/java/org/apache/camel/component/milvus/MilvusProducer.java
@@ -20,12 +20,14 @@ import java.util.concurrent.ExecutorService;
import io.milvus.client.MilvusClient;
import io.milvus.grpc.MutationResult;
+import io.milvus.grpc.QueryResults;
import io.milvus.param.R;
import io.milvus.param.RpcStatus;
import io.milvus.param.collection.CreateCollectionParam;
import io.milvus.param.collection.LoadCollectionParam;
import io.milvus.param.dml.DeleteParam;
import io.milvus.param.dml.InsertParam;
+import io.milvus.param.dml.QueryParam;
import io.milvus.param.dml.UpsertParam;
import io.milvus.param.highlevel.dml.SearchSimpleParam;
import io.milvus.param.highlevel.dml.response.SearchResponse;
@@ -82,6 +84,9 @@ public class MilvusProducer extends DefaultProducer {
case SEARCH:
search(exchange);
break;
+ case QUERY:
+ query(exchange);
+ break;
case DELETE:
delete(exchange);
break;
@@ -156,6 +161,19 @@ public class MilvusProducer extends DefaultProducer {
}
+ private void query(Exchange exchange) throws Exception {
+ final Message in = exchange.getMessage();
+ final QueryParam body = in.getMandatoryBody(QueryParam.class);
+
+ this.client.loadCollection(
+ LoadCollectionParam.newBuilder().withCollectionName(getEndpoint().getCollection()).withSyncLoad(true).build());
+ R<QueryResults> result = this.client.query(body);
+
+ handleResponseStatus(result);
+ populateResponse(result, exchange);
+
+ }
+
private void delete(Exchange exchange) throws Exception {
final Message in = exchange.getMessage();
final DeleteParam body = in.getMandatoryBody(DeleteParam.class);
diff --git a/components/camel-milvus/src/test/java/org/apache/camel/component/milvus/it/MilvusComponentIT.java b/components/camel-milvus/src/test/java/org/apache/camel/component/milvus/it/MilvusComponentIT.java
index 6220150f19c..8b2108c1dc8 100644
--- a/components/camel-milvus/src/test/java/org/apache/camel/component/milvus/it/MilvusComponentIT.java
+++ b/components/camel-milvus/src/test/java/org/apache/camel/component/milvus/it/MilvusComponentIT.java
@@ -22,12 +22,14 @@ import java.util.Random;
import io.milvus.common.clientenum.ConsistencyLevelEnum;
import io.milvus.grpc.DataType;
+import io.milvus.grpc.QueryResults;
import io.milvus.param.IndexType;
import io.milvus.param.MetricType;
import io.milvus.param.collection.CreateCollectionParam;
import io.milvus.param.collection.FieldType;
import io.milvus.param.dml.DeleteParam;
import io.milvus.param.dml.InsertParam;
+import io.milvus.param.dml.QueryParam;
import io.milvus.param.dml.UpsertParam;
import io.milvus.param.highlevel.dml.SearchSimpleParam;
import io.milvus.param.highlevel.dml.response.SearchResponse;
@@ -206,6 +208,27 @@ public class MilvusComponentIT extends MilvusTestSupport {
@Test
@Order(6)
+ public void query() {
+ QueryParam searchSimpleParam = QueryParam.newBuilder()
+ .withCollectionName("test")
+ .withExpr("userAge>0")
+ .withOutFields(Lists.newArrayList("userAge"))
+ .withConsistencyLevel(ConsistencyLevelEnum.STRONG)
+ .build();
+
+ Exchange result = fluentTemplate.to("milvus:test")
+ .withHeader(Milvus.Headers.ACTION, MilvusAction.QUERY)
+ .withBody(
+ searchSimpleParam)
+ .request(Exchange.class);
+
+ assertThat(result).isNotNull();
+ assertThat(result.getException()).isNull();
+ assertThat(result.getMessage().getBody(QueryResults.class).getFieldsDataCount() == 2);
+ }
+
+ @Test
+ @Order(7)
public void delete() {
DeleteParam delete = DeleteParam.newBuilder()
.withCollectionName("test")