davsclaus opened a new pull request, #29036:
URL: https://github.com/apache/camel/pull/29036

   Fixes [CAMEL-26210](https://issues.apache.org/jira/browse/CAMEL-26210).
   
   All six points of the issue are handled in `SpringAiVectorStoreProducer`.
   
   ### 1. DELETE deleted the ids that ADD or SIMILARITY_SEARCH put in the header
   `processDelete` read `CamelSpringAiVectorStoreDocumentIds` before the body. 
ADD and SIMILARITY_SEARCH set that header to their own output ids, so a later 
DELETE in the same route deleted those documents (for example everything a 
search just found) instead of the ids in the body.
   
   Now DELETE takes the ids from the body first: an id, a `Document`, or a List 
of ids or of `Document`. The header is used only when there is no body (or an 
empty one). The documented "search, then delete" chain still works, because the 
body of SIMILARITY_SEARCH is the List of `Document` found. A List with another 
element type (for example an `Integer`) now fails with a message naming the 
type. Before, it was cast unchecked to `List<String>`.
   
   ### 2. ADD with a `float[]` body and no input-text header stored `"[F@..."`
   A `float[]` body without `CamelSpringAiEmbeddingInputText` now fails with an 
`IllegalArgumentException` that names the header. A List of `float[]` body now 
needs `CamelSpringAiEmbeddingInputTexts` with one text per vector. Before, a 
mismatch silently dropped the extra vectors or texts.
   
   ### 3. SIMILARITY_SEARCH after spring-ai-embeddings searched for 
`float[].toString()`
   With a `float[]` body, the query is now the text of the 
`CamelSpringAiEmbeddingInputText` header. Without that header, it fails.
   
   ### 4. A leftover `CamelSpringAiEmbeddingInputText` header made ADD ignore 
the body
   The input-text headers are now used only together with a vector body 
(`float[]` or a List of `float[]`). A `Document`, text or List body is stored 
as it is, even with a leftover header. This applies to both the singular and 
the plural header, because the plural one had the same problem: a List of texts 
or Documents was replaced by the header texts.
   
   ### 5. ADD with a List of Map dropped every element, then failed
   A List element that is not a `Document` or a `String` now fails with a 
message naming its type. Before, such elements were skipped, and the request 
then failed in the vector store with "Documents list cannot be empty". I chose 
to fail rather than convert a Map, because there is no agreed Map shape for a 
Document.
   
   ### 6. DocumentsDeleted counts the ids asked for, not the ids deleted
   The Spring AI `VectorStore.delete` API returns nothing, so the count cannot 
be exact. The header description and the component doc now say it is the number 
of ids given to the vector store.
   
   ### Tests
   `SpringAiVectorStoreComponentTest` has 10 new tests: 5 for ADD (leftover 
headers with a Document or text-list body, vector without text, mismatched 
texts, List of Map), 2 for SIMILARITY_SEARCH (`float[]` body with and without 
the header; a mocked `VectorStore` captures the query), and 3 for DELETE (body 
id after a search, a List of `Document`, a List of `Integer`). All 10 failed 
without the fix. The module's 19 unit tests pass.
   
   `QdrantVectorStoreIT` could not run locally, because the local Ollama does 
not have the `embeddinggemma:300m` model. Its DELETE tests send only the header 
without a body, which still works.
   
   ### Docs and generated files
   - The `@BodyTypes` text and carriers are updated. DELETE now also takes a 
pojo (`Document`) or no body (header). SIMILARITY_SEARCH also takes a list 
(`float[]`).
   - The header descriptions of `DocumentIds` and `DocumentsDeleted` are 
updated, and the catalog JSON/adoc and the endpoint DSL are regenerated.
   - The component doc is updated: the DELETE example now puts the ids in the 
body.
   - Upgrade guide 4.24: there is a new `camel-spring-ai-vector-store` section, 
because DELETE now prefers the body over the header, and vectors without text 
and unknown List elements now fail.
   
   ### For the reviewer
   A route that sets the `CamelSpringAiVectorStoreDocumentIds` header and also 
has an unrelated text body now deletes the body text as an id. The upgrade 
guide says to clear the body or to put the ids in the body. A separate input 
header would have avoided this, but it would rename what users set today. So I 
followed the first proposal in the issue (body first).
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to