Skip to content

Conversation

@jairad26
Copy link
Contributor

@jairad26 jairad26 commented Nov 3, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • There was a bug in the search api, where search queries were not auto-embedded. This PR fixes that and adds a test to ensure that search api explicitly works on autoembedding in both the read and write path. previously, there were tests on the underlying search class and manually calling the embed function to ensure the embedded results were valid. this test is e2e, ensuring that adds and queries return the desired result and the search api functions as intended
  • New functionality
    • ...

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

Copy link
Contributor Author

jairad26 commented Nov 3, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@jairad26 jairad26 marked this pull request as ready for review November 3, 2025 23:38
@jairad26 jairad26 requested a review from tanujnay112 November 3, 2025 23:38
@propel-code-bot
Copy link
Contributor

propel-code-bot bot commented Nov 3, 2025

Fix auto-embedding of string KNN queries in Collection.search() (sparse & dense)

This PR patches a bug where Collection.search() forwarded the original Search objects rather than their auto-embedded versions, causing string queries (especially sparse vector cases) to bypass the embedding function. The fix is a one-line change that passes embedded_searches (cast to List[Search]) into the client call, ensuring both dense and sparse auto-embedding paths work. A new end-to-end pytest adds 68 LOC to guard against regressions by inserting documents with a registered SparseEmbeddingFunction and asserting correct retrieval via string-based queries.

Key Changes

• Updated chromadb/api/models/Collection.py to pass embedded_searches via cast(List[Search], embedded_searches).
• Added extensive e2e test test_search_api_uses_embedded_searches_with_sparse_embeddings and helper TestSparseEmbeddingFunction in chromadb/test/api/test_schema_e2e.py (~68 LOC).

Affected Areas

chromadb/api/models/Collection.search() implementation
• Test suite for schema/search behaviour

This summary was automatically generated by @propel-code-bot

schema = Schema().create_index(
key="sparse_field",
config=SparseVectorIndexConfig(
source_key=Key.DOCUMENT, # type: ignore[arg-type]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we cut a ticket for this type error? It should not happen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea ill cut it. it's weird, doesnt give red squiggly its only mypy

@jairad26 jairad26 force-pushed the jai/fix-sparse-autoembed branch from 8e19882 to 0eaa460 Compare November 3, 2025 23:54
@jairad26 jairad26 force-pushed the jai/fix-sparse-autoembed branch from 0eaa460 to 7188c4c Compare November 4, 2025 00:00
@jairad26 jairad26 merged commit 4da9d91 into main Nov 4, 2025
62 checks passed
chroma-droid pushed a commit that referenced this pull request Nov 5, 2025
## Description of changes

_Summarize the changes made by this PR._

- Improvements & Bug fixes
- There was a bug in the search api, where search queries were not
auto-embedded. This PR fixes that and adds a test to ensure that search
api explicitly works on autoembedding in both the read and write path.
previously, there were tests on the underlying search class and manually
calling the embed function to ensure the embedded results were valid.
this test is e2e, ensuring that adds and queries return the desired
result and the search api functions as intended
- New functionality
  - ...

## Test plan

_How are these changes tested?_

- [ ] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Migration plan

_Are there any migrations, or any forwards/backwards compatibility
changes needed in order to make sure this change deploys reliably?_

## Observability plan

_What is the plan to instrument and monitor this change?_

## Documentation Changes

_Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
section](https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com)?_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants