Federico Mariani created CAMEL-27242:
----------------------------------------

             Summary: camel-spring-ai-vector-store - UPSERT and vector search, 
to store and search with the vectors of spring-ai-embeddings
                 Key: CAMEL-27242
                 URL: https://issues.apache.org/jira/browse/CAMEL-27242
             Project: Camel
          Issue Type: Improvement
          Components: camel-spring-ai
            Reporter: Federico Mariani
            Assignee: Federico Mariani


After spring-ai-embeddings, the body is the {{float[]}} vector of a text. Today 
ADD stores the text and the vector store embeds it again with its own 
{{EmbeddingModel}}; the vector only goes in the document metadata 
({{embedding}}, {{precomputed_embedding}}). SIMILARITY_SEARCH embeds the text 
of the {{CamelSpringAiEmbeddingInputText}} header again. Spring AI 2.0 had no 
API to write or search with a vector.

Elsewhere in Camel, the vector computed by the embeddings component is the one 
that is stored and searched:
* langchain4j-embeddingstore ADD and SEARCH use the {{Embedding}} of 
langchain4j-embeddings; it embeds by itself only with an {{embeddingModel}} and 
no embedding header.
* pgvector, qdrant, milvus, pinecone, weaviate, neo4j and infinispan take the 
vector, directly or through their {{<name>:embeddings}} data type transformers. 
pgvector, qdrant, milvus and pinecone call the write {{UPSERT}}.
* The openai embeddings documentation chains the {{List<Float>}} body straight 
into pgvector UPSERT and SIMILARITY_SEARCH.

Spring AI 2.1.0 adds {{VectorStore.upsert(List<EmbeddedDocument>)}} and 
{{VectorStoreRetriever.similaritySearch(float[], SearchRequest)}}, supported by 
the Chroma, Couchbase, Elasticsearch, MariaDB, MongoDB Atlas, Neo4j, 
OpenSearch, PgVector, Qdrant, Redis and Typesense stores. The others, such as 
{{SimpleVectorStore}}, throw {{UnsupportedOperationException}} before writing 
anything.

h3. Proposal

* A new {{UPSERT}} operation: a {{float[]}} body with the 
{{CamelSpringAiEmbeddingInputText}} header, or a List of {{float[]}} with the 
{{CamelSpringAiEmbeddingInputTexts}} header, is written with {{upsert}} as it 
is; the store's {{EmbeddingModel}} is not called. A store without upsert fails 
with a clear message.
* An option for SIMILARITY_SEARCH of a {{float[]}} body to search with the 
vector instead of embedding the header text. Off by default.
* ADD keeps its behaviour. Making the vector the default would silently mix two 
embedding spaces when spring-ai-embeddings uses another model than the store, 
or fail on a dimension mismatch.

_Claude Code on behalf of Croway_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to