perf(search): remove wildcard matching and use match phrase prefix only#2273
Merged
perf(search): remove wildcard matching and use match phrase prefix only#2273
Conversation
Contributor
📝 WalkthroughSummary by CodeRabbit
WalkthroughOpenSearch query building was simplified by removing Unicode grapheme-length validation and conditional logic that previously created composite bool queries for short terms. Match phrase prefix queries now consistently include a Changes
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@rust/cloud-storage/opensearch_client/src/search/query.rs`:
- Line 28: Add a short doc comment above the constant
MATCH_PHRASE_PREFIX_MAX_EXPANSIONS explaining why it is set to 256 (noting
OpenSearch's default is 50), that the higher value compensates for removed
wildcard matching, and mention the tradeoff (e.g., increased index memory and
term expansion cost) so future maintainers understand the rationale and
potential impact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b2484559-65e9-46fc-8aeb-0c19c76498d1
📒 Files selected for processing (3)
rust/cloud-storage/opensearch_client/src/search/builder/test.rsrust/cloud-storage/opensearch_client/src/search/query.rsrust/cloud-storage/opensearch_client/src/search/query/test.rs
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.
https://github.com/macro-inc/macro-api/pull/2491/changes was merged to account for match phrase prefix not really working with short words at the end of the last term. however, this combo query results in very slow search results, as demonstrated by all our slow search logs. technically this combo query wasn't really a match phrase prefix, but i think match phrase prefix is acceptable for what we want anyways. bumping max expansions will increase the number of possibly matching phrases but it might miss the prefix. in the future we can use an index prefixes mapping to get everything we need