Claus Ibsen created CAMEL-27622:
-----------------------------------
Summary: camel-spring-ai-vector-store: ADD re-embeds vectors,
DELETE error, no producer labels
Key: CAMEL-27622
URL: https://issues.apache.org/jira/browse/CAMEL-27622
Project: Camel
Issue Type: Bug
Components: camel-spring-ai
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-spring-ai-vector-store
for CAMEL-23832 (PR https://github.com/apache/camel/pull/30961).
These are separate problems of the component; the descriptions PR only
documents the current behavior.
h4. 1. ADD of a float[] body does not use the vector
After spring-ai-embeddings the body is a {{float[]}} (or a {{List}} of
{{float[]}}) with the text in the {{CamelSpringAiEmbeddingInputText(s)}}
header. {{SpringAiVectorStoreProducer.processAdd()}} then calls
{{createDocumentWithEmbedding()}}, which puts the vector into the {{embedding}}
and {{precomputed_embedding}} metadata of a new {{Document}} and calls
{{VectorStore.add()}}.
The vector stores of Spring AI do not read this metadata: {{add()}} embeds the
text again with the embedding model of the store, and the {{float[]}} is kept
as document metadata. The user pays for a second embedding call and gets an
extra metadata entry, while the {{@BodyTypes}} text of the endpoint says that
ADD "adds the float[] body".
Proposed change: drop the {{embedding}} and {{precomputed_embedding}} metadata
and say in the docs that ADD of a vector embeds the text again, or let ADD of a
{{float[]}} body write the vector as UPSERT does.
h4. 2. The filterExpression option changes the error of DELETE
In {{SpringAiVectorStoreProducer.processDelete()}}, when the body and the
{{CamelSpringAiVectorStoreDocumentIds}} header give no ids, the producer reads
the filter expression from the {{CamelSpringAiVectorStoreFilterExpression}}
header or the {{filterExpression}} option. If one is set, it throws
{{UnsupportedOperationException}} ("Delete by filter expression is not
supported by all vector stores"), otherwise {{IllegalArgumentException}}.
The {{filterExpression}} option is meant for SIMILARITY_SEARCH. On an endpoint
that has it set, a DELETE without ids fails with a message about delete by
filter, which the component never supports, instead of the message that the ids
are missing.
Proposed change: either support delete by filter with
{{VectorStore.delete(String filterExpression)}} of Spring AI, or ignore the
filter in DELETE and always fail with the missing ids message.
h4. 3. The options and headers have no producer label
In {{SpringAiVectorStoreConfiguration}}, the options {{operation}}, {{topK}},
{{similarityThreshold}}, {{filterExpression}} and {{searchByVector}} have no
{{label}} on {{@UriParam}}. The headers in {{SpringAiVectorStoreHeaders}} have
no {{label}} either. The component is producer only ({{producerOnly = true}}),
so the catalog and the docs list these options under "common" instead of
"producer".
Proposed change: add {{label = "producer"}} to these options and headers.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)