Skip to content

Conversation

@codetheweb
Copy link
Contributor

@codetheweb codetheweb commented May 12, 2025

Description of changes

The full-text reader had a bug where it used the positions of tokens to determine whether the tokens appeared sequentially, rather than using the byte offset of tokens. This was problematic because the index stores byte offsets. Since Unicode characters can be many bytes wide, we cannot guarantee that the stored byte offsets are strictly consecutive.

Test plan

How are these changes tested?

Added a test that fails on main.

Documentation Changes

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

n/a

@github-actions
Copy link

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)

@codetheweb codetheweb force-pushed the bug-fts-reader-byte-offset-vs-token-position branch from 69dca61 to 8891e68 Compare May 12, 2025 20:56
@codetheweb codetheweb marked this pull request as ready for review May 12, 2025 21:07
@codetheweb codetheweb requested review from HammadB and rescrv May 12, 2025 21:07
@propel-code-bot
Copy link
Contributor

Fix for Full-Text Search with Unicode Characters

This PR fixes a bug in the full-text reader where token positions were used instead of byte offsets when determining if tokens appeared sequentially. Since Unicode characters can be variable-width (multiple bytes), using token positions led to incorrect search results when texts contained multi-byte characters. The fix uses byte offsets to properly handle Unicode text.

Key Changes:
• Changed position adjustment logic to use byte offsets instead of token positions
• Simplified the token position adjustment algorithm
• Added a test case for documents containing multi-byte characters

Affected Areas:
• Full-text search implementation in rust/index/src/fulltext/types.rs

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

@codetheweb codetheweb enabled auto-merge (squash) May 12, 2025 21:37
@codetheweb codetheweb merged commit 796610e into main May 12, 2025
70 checks passed
@codetheweb codetheweb deleted the bug-fts-reader-byte-offset-vs-token-position branch May 12, 2025 21:55
narner pushed a commit to narner/chroma that referenced this pull request May 14, 2025
…chroma-core#4531)

## Description of changes

The full-text reader had a bug where it used the positions of tokens to
determine whether the tokens appeared sequentially, rather than using
the byte offset of tokens. This was problematic because the index stores
byte offsets. Since Unicode characters can be many bytes wide, we cannot
guarantee that the stored byte offsets are strictly consecutive.

## Test plan

_How are these changes tested?_

Added a test that fails on main.

## 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)?_

n/a
itaismith pushed a commit that referenced this pull request May 23, 2025
…#4531)

## Description of changes

The full-text reader had a bug where it used the positions of tokens to
determine whether the tokens appeared sequentially, rather than using
the byte offset of tokens. This was problematic because the index stores
byte offsets. Since Unicode characters can be many bytes wide, we cannot
guarantee that the stored byte offsets are strictly consecutive.

## Test plan

_How are these changes tested?_

Added a test that fails on main.

## 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)?_

n/a
Inventrohyder pushed a commit to Inventrohyder/chroma that referenced this pull request Aug 5, 2025
…chroma-core#4531)

## Description of changes

The full-text reader had a bug where it used the positions of tokens to
determine whether the tokens appeared sequentially, rather than using
the byte offset of tokens. This was problematic because the index stores
byte offsets. Since Unicode characters can be many bytes wide, we cannot
guarantee that the stored byte offsets are strictly consecutive.

## Test plan

_How are these changes tested?_

Added a test that fails on main.

## 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)?_

n/a
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