This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch delete-by-ids-pinecone in repository https://gitbox.apache.org/repos/asf/camel.git
commit b8290d9966f0b7da3ddb595c3a686313a362a2f5 Author: Andrea Cosentino <[email protected]> AuthorDate: Wed Sep 10 15:22:56 2025 +0200 Camel-Pinecone: Add deleteById operation Signed-off-by: Andrea Cosentino <[email protected]> --- .../component/pinecone/PineconeVectorDbAction.java | 3 ++- .../pinecone/PineconeVectorDbProducer.java | 26 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/PineconeVectorDbAction.java b/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/PineconeVectorDbAction.java index 406b27aa1b6..bd68cd90d00 100644 --- a/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/PineconeVectorDbAction.java +++ b/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/PineconeVectorDbAction.java @@ -26,5 +26,6 @@ public enum PineconeVectorDbAction { DELETE_COLLECTION, QUERY, QUERY_BY_ID, - UPDATE + UPDATE, + DELETE_BY_ID } diff --git a/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/PineconeVectorDbProducer.java b/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/PineconeVectorDbProducer.java index c60a513f556..4965534c59a 100644 --- a/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/PineconeVectorDbProducer.java +++ b/components/camel-ai/camel-pinecone/src/main/java/org/apache/camel/component/pinecone/PineconeVectorDbProducer.java @@ -22,6 +22,7 @@ import java.util.concurrent.ExecutorService; import com.google.protobuf.Struct; import io.pinecone.clients.Index; import io.pinecone.clients.Pinecone; +import io.pinecone.proto.DeleteResponse; import io.pinecone.proto.FetchResponse; import io.pinecone.proto.UpdateResponse; import io.pinecone.proto.UpsertResponse; @@ -96,6 +97,9 @@ public class PineconeVectorDbProducer extends DefaultProducer { case QUERY_BY_ID: queryById(exchange); break; + case DELETE_BY_ID: + deleteByIds(exchange); + break; default: throw new UnsupportedOperationException("Unsupported action: " + action.name()); } @@ -250,6 +254,23 @@ public class PineconeVectorDbProducer extends DefaultProducer { this.client.deleteCollection(collectionName); } + private void deleteByIds(Exchange exchange) throws Exception { + final Message in = exchange.getMessage(); + List elements = in.getMandatoryBody(List.class); + String indexName = getEndpoint().getConfiguration().getIndexName(); + + if (in.getHeader(PineconeVectorDb.Headers.INDEX_NAME, String.class) != null) { + indexName = in.getHeader(PineconeVectorDb.Headers.INDEX_NAME, String.class); + } + + Index index = this.client.getIndexConnection(indexName); + + DeleteResponse result + = index.deleteByIds(elements); + + populateDeleteResponse(result, exchange); + } + private void fetch(Exchange exchange) throws Exception { final Message in = exchange.getMessage(); List elements = in.getMandatoryBody(List.class); @@ -361,4 +382,9 @@ public class PineconeVectorDbProducer extends DefaultProducer { Message out = exchange.getMessage(); out.setBody(r); } + + private void populateDeleteResponse(DeleteResponse r, Exchange exchange) { + Message out = exchange.getMessage(); + out.setBody(r); + } }
