Repository navigation
Conversation
Wire Chroma into VectorStoreRetriever.similaritySearch(float[], SearchRequest) the same way as Elasticsearch/pgvector/Redis/Qdrant (and OpenSearch spring-projects#7140): validate the query vector width against the embedding model dimensions and reuse the existing collection query path. Copy Chroma metadata before adding the distance field so immutable maps from the API cannot fail the search. Signed-off-by: lejuho <zedd1324@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VectorStoreRetriever.similaritySearch(float[], SearchRequest)lets callers search with a precomputed query embedding (added in 89dc8db for pgvector, Redis, Elasticsearch, and Qdrant).ChromaVectorStorealready queried byfloat[]through its collection path, but did not overridedoSimilaritySearch(float[], SearchRequest), so the new API threwUnsupportedOperationException.Wire Chroma the same way as Elasticsearch: validate the query vector width against the embedding model's reported dimensions and reuse the existing collection query path. Also copy Chroma metadata into a mutable map before adding the distance field, so an immutable metadata map from the API cannot fail the search. Update the vector-store docs to list Chroma among the stores that support caller-supplied query embeddings.
Tests
shouldSearchWithCallerSuppliedQueryEmbeddingWithoutEmbeddingModel— searches with afloat[]and never callsEmbeddingModel.embedshouldRejectWrongWidthQueryEmbedding— rejects a dimension mismatch./mvnw -Dmaven.build.cache.enabled=false -pl vector-stores/spring-ai-chroma-store test -Dtest='ChromaVectorStoreTests,ChromaApiTest,ChromaFilterExpressionConverterWhereJsonTests' -Ddisable.checks=false— 10 tests, 0 failuresPrior art: Elasticsearch / pgvector / Redis / Qdrant in 89dc8db; OpenSearch in #7140.