Repository navigation
feat(search): OpenSearch relevance with typos, prefixes, phrases and recency - #9864
Draft
salman1993 wants to merge 6 commits into
Draft
salman1993 wants to merge 6 commits into
salman1993 wants to merge 6 commits into
Conversation
salman1993
force-pushed
the
smohammed/opensearch-switch-shadow
branch
from
November 24, 2026 21:14
4c7562a to
de3cc36
Compare
salman1993
force-pushed
the
smohammed/opensearch-relevance
branch
from
November 24, 2026 21:22
85bc1c6 to
253687d
Compare
salman1993
force-pushed
the
smohammed/opensearch-switch-shadow
branch
from
November 25, 2026 00:25
de3cc36 to
1942416
Compare
salman1993
force-pushed
the
smohammed/opensearch-relevance
branch
from
November 25, 2026 00:34
253687d to
b0aef97
Compare
salman1993
force-pushed
the
smohammed/opensearch-switch-shadow
branch
from
November 25, 2026 18:49
1942416 to
6a93e8c
Compare
salman1993
force-pushed
the
smohammed/opensearch-relevance
branch
from
November 25, 2026 19:27
b0aef97 to
367d560
Compare
salman1993
force-pushed
the
smohammed/opensearch-switch-shadow
branch
from
November 25, 2026 19:58
6a93e8c to
107f35e
Compare
salman1993
force-pushed
the
smohammed/opensearch-relevance
branch
from
November 25, 2026 20:08
367d560 to
2bf6f7d
Compare
salman1993
force-pushed
the
smohammed/opensearch-switch-shadow
branch
2 times, most recently
from
November 25, 2026 20:50
117aef8 to
f406300
Compare
salman1993
force-pushed
the
smohammed/opensearch-relevance
branch
from
November 25, 2026 20:50
2bf6f7d to
b5ddd4d
Compare
salman1993
force-pushed
the
smohammed/opensearch-switch-shadow
branch
from
November 26, 2026 00:23
f406300 to
ba75249
Compare
salman1993
force-pushed
the
smohammed/opensearch-relevance
branch
from
November 26, 2026 16:19
b5ddd4d to
1bac232
Compare
…recency Message search on OpenSearch now matches words one or two typos away and word prefixes, keeps letters and digits of a token together, and ranks exact phrases and nearby words higher. Newer messages rank higher through an age rescore. Phrase, proximity and age are applied as rescores over the top 1,000 hits, not to every match, so a common word in a large community stays cheap. Relevance results end at that window, which is tied at compile time to the largest page the relay serves. The mapping version moves to 2, so the index is recreated and backfilled. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Salman Mohammed <smohammed@squareup.com>
The analyzers and the decay rescore pass on a NextGen Serverless collection. Serverless reports every shard count as zero, so only timed_out can show a partly failed search there. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: Salman Mohammed <smohammed@squareup.com>
The relay clears the backfill progress itself when it creates the index. Signed-off-by: Salman Mohammed <smohammed@squareup.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hen sorting by time The query analyzers did not split words the way the index analyzers do, so part of an identifier (snake_case of snake_case_name, OutboxBatch of SearchOutboxBatch) found nothing, and neither did the start of an identifier longer than 24 characters in prefix mode. Sorted by time, a search matched typos too. Weights do not order those results, so for a short word the other words one letter away pushed the exact matches out. It also asked for scores nothing reads, which made a common word's search about six times slower on a million messages. Signed-off-by: Salman Mohammed <smohammed@squareup.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
salman1993
force-pushed
the
smohammed/opensearch-relevance
branch
from
November 26, 2026 17:57
39227f9 to
8b7d435
Compare
…, then apart A query's identifier is split like indexed text, which makes its parts a phrase on the exact field. The stem and prefix fields keep no positions, so parts apart still match there, below. Cover both for snake and camel case, alone, in a longer query and unfinished. Signed-off-by: Salman Mohammed <smohammed@squareup.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- In prefix mode the unfinished last word now also matches with a typo, from four characters, so a single misspelt word finds its message below the exact spelling. Shorter words are one edit from too many others. Newest order still matches no typos. - Score parts report an age factor of 1 for a search sorted by time, which applies none, and the doc no longer names a stale window size. - Drop the search analyzers that equalled their index analyzers. - The age factor uses abs_diff, so extreme timestamps cannot overflow, and the half-life is a whole number of days. - The deployment doc says why prefix searches overlap less in shadow. Signed-off-by: Salman Mohammed <smohammed@squareup.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Stacked on #9863; #9838, #9862 and #9947 are merged. The earlier PRs fill an OpenSearch message index and add a relay-wide switch with a shadow mode. Until now the OpenSearch query was a plain word match, so shadow results could not be judged. This PR adds the relevance model: typos, partial words, rare words, phrases and recency. Search for users is unchanged while the flag stays at 0.
Mapping version 2 (
buzz-messages-v2). Message text is indexed three ways: whole words (with accents folded and compound words split), stems, and prefixes of 2 to 10 characters. A partial word longer than 10 characters is cut to 10 at query time, so it still matches.Query. It lives in
crates/buzz-search/src/opensearch/relevance.rs:logandlag), and with time as the only order they pushed exact matches out: on a million messageslogmatched 390 messages exactly and 1,623 with typos. Scoring made a newest-first search for a common word about six times slower (13 ms against 2 ms)._,.and case changes like the indexed text, so part of an identifier finds it (snake_caseofsnake_case_name,OutboxBatchofSearchOutboxBatch,BUZZ_OPENof a longer variable name).foo_bartherefore also finds a message holdingfooandbarapart.2<75%).0.2 + 0.8 × 0.5^(age / 30 days). An old message keeps at least a fifth of its score.Upgrade.
ensure()refuses to start indexing when the alias points at an index with another mapping version. Rows stay queued. The fix is indocs/opensearch-search-deployment.md: delete the old index, and the relay creates the new one, clears the backfill progress and rebuilds it. The same doc now covers edits, the refresh delay and lag after an outage.Worth knowing:
index_prefixescame out larger than edge n-grams.Related issue
N/A. Stacked on #9863; only the top commit is this PR.
Testing
On a laptop with local Postgres and OpenSearch 2.19.3 (512 MiB heap), 1 million synthetic messages:
Query p50 was 4, 6 and 10 ms for queries that match 10k, 100k and 790k messages.
A real relay with the flag at 1 ran prefix and typo searches; each wrote a shadow comparison line with OpenSearch hits.
A leftover version 1 index was refused and rows stayed queued. The documented rebuild brought the index up at version 2.
relevance_pages_tile_one_order_up_to_the_rescore_windowchecks that pages do not repeat or skip hits.Not measured: Amazon OpenSearch Serverless, production-shaped data, and relevance quality against real queries.
🤖 Generated with Claude Code