You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(search): stop meaning-based search from returning the whole library - #4058
Closes#3963
Related issue: N/A
Validation tasks: none
Other clients: Apple N/A (server change, the app already shows what the search returns); Android N/A (server change, same reason); Roku N/A (server change, same reason)
With Match by meaning as well as words on, every search of two or more words returned every movie and series in the library. One-word searches were fine because they stay keyword-only. Silo sent Meilisearch a hybrid query with no score floor, and the meaning half of a hybrid query ranks every document that has a vector, however unrelated. This change keeps keyword matches as they are and only lets meaning matches through when they're actually similar to the search. It covers the native search (/api/v2/catalog/query and the catalog list) and jellycompat search, which go through the same provider.
Approach
A hybrid search now runs as a federated Meilisearch search of two queries instead of one hybrid query:
the keyword query, the same one keyword mode sends;
a meaning-only query (semanticRatio: 1 with the query vector) that carries a rankingScoreThreshold.
I didn't put the threshold on the hybrid query itself because Meilisearch applies a hybrid query's rankingScoreThreshold to both halves. Keyword scores and vector similarities sit on different scales, so a floor high enough to drop unrelated meaning matches also drops weak keyword matches, such as two words far apart in an overview. With the queries split, every keyword match stays. The federation weights are the configured semantic ratio and one minus it, which is how Meilisearch weighs the two halves inside a hybrid query, and federation keeps one copy of an item both queries find. Mixed episode searches keep their keyword-only episode query.
The floor is a cosine similarity of 0.3 between the search and an item, converted to the score Meilisearch reports:
full-precision vectors: (1 + cos) / 2, so 0.65;
binary-quantized vectors (the default): the share of agreeing sign bits, about 1 - acos(cos)/π, so 0.597 for a 3072-dimension model. Silo pads smaller models with zeros to 3072 dimensions, and padded bits always agree, so the floor is scaled by the share of dimensions the model fills (0.80 for 1536 dimensions, 0.95 for 384-dimension MiniLM).
0.3 is a starting value. It sits above the cosine unrelated text usually gets from the OpenAI text-embedding-3 models and MiniLM. I checked it end to end with MiniLM (see Evidence) but not with the reporter's text-embedding-3-large, so I'll ask the reporter to try it on their setup.
A federated hybrid search that fails for a reason other than "federation unsupported" now retries as a Meilisearch keyword search in the offset path too, as the cursor path already did, instead of going straight to PostgreSQL. When either fallback happens part-way through a scan, the scan restarts from the first hit in keyword mode, so no hybrid-ranked items or offsets carry over.
No API shape changes. search_diagnostics.mode still reports hybrid.
Validation
Focused Go tests for internal/catalog (Meilisearch and catalog search), with -race: pass. The new test drives Search through a fake Meilisearch. It fails on the old routing and passes with this change, and it covers the cursor path, the offset path, and a one-word search staying a plain keyword search.
Fork CI on 412c7d0 (lint, Go tests, web and the rest): pass. This PR's CI covers the later fallback fix.
Real Meilisearch 1.56.1, no Silo: indexes with Silo's settings, full-precision and binary-quantized, and hand-made vectors at known cosines. Meilisearch accepts the exact federated body (200). The reported similarities match the floor maths, including padded bits counting as agreeing. Meaning matches below the floor drop out, a two-word overview match with a far-off vector still comes back through the keyword query, and an item both queries find appears once.
End to end: the old and new Silo builds against the same local index with real MiniLM embeddings, through the API and the iOS app (see Evidence).
Evidence
Local Silo with Meilisearch 1.56.1, a 50-film test library matched through TMDB, and embeddings from Ollama all-minilm. Meaning-based search was on with the defaults (binary-quantized vectors, share 0.50, 100% coverage). Both runs used the same database, index and settings; only the Silo binary changed: before 0387303d9 (main), after 412c7d018.
Search
Before
After
Model Citizen
hybrid, 50 items (whole library)
hybrid, 6 items
past lives
hybrid, 50 items
hybrid, 2 items (Looper, Cloud Atlas)
Minority Report
hybrid, 50 items, exact match first
hybrid, 1 item (the exact match)
time loop
hybrid, 50 items
hybrid, 2 items (Looper, Edge of Tomorrow)
Conclave (one word)
keyword, 0 items
keyword, 0 items
The iOS app (silo-apple main 5780c84f, iPhone simulator) shows the same counts on its Search screen: "50 results" before, "6 results" and "2 results" after.
The floor doesn't depend on the embedding model. Models that give unrelated text a cosine well above 0.3 (some bge and e5 models) will still let through more meaning matches than they should, and a model that scores related text below 0.3 will lose some. If that turns out to matter, the floor could become a setting next to the meaning-based share.
The binary-quantized conversion assumes sign bits behave like random hyperplanes. Meilisearch keeps each dimension's own sign, so on real embeddings the bit agreement at cosine 0.3 can drift from 0.597. It holds best for models whose dimensions are centred on zero, such as the OpenAI models.
Hybrid search now needs Meilisearch federated search (v1.10 or later); the Compose file ships v1.54. On an older Meilisearch the existing "federation unsupported" path falls back to keyword search.
Negative terms (-word) now narrow only the keyword query. A meaning-only Meilisearch search never applies q, so an item containing the excluded word can still come back as a meaning match if it clears the floor. The old single hybrid query applied them to both halves.
Meilisearch's shortcut that skips the meaning search when keyword results are already strong no longer applies, so a search can show a few more meaning matches below strong keyword hits.
Checklist
I read and can explain the complete diff.
This pull request addresses one concern.
Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
The Evidence section shows every change a user can see, or how I checked a change nobody sees.
AI Disclosure
Harness: Claude Code (desktop app)
Tool(s): Claude Code (Bash, file edits, a reviewer subagent), GitHub CLI, Xcode iOS Simulator
Model(s): claude-opus-5-5
Involvement: AI-assisted. AI-assisted with Claude Opus. I directed the task and designed the work.
Adversarial review: a fresh Claude Code subagent reviewed the diff against the Meilisearch v1.54.0 source for ordering, fallback, pagination and floor-maths regressions. It found nothing blocking. It flagged that the fixed floor ignores the embedding model and that the quantized estimate can drift; both are under Risks. A stale comment about the fallback was corrected.
Note
Add rankingScoreThreshold support to Meilisearch federated queries
Adds an optional ranking-score threshold field to the federated query payload in search_meilisearch_client.go. It is omitted from JSON when zero, and is intended for the meaning-only search query to filter out low-relevance results. Risk: check the payload marshal logic if other callers of meilisearchFederatedQuery rely on the exact JSON shape.
With semantic search on, a search of two or more words ran a Meilisearch
hybrid query with no score floor. Its meaning half ranks every item that
has a vector, so every such search returned every movie and series.
Hybrid searches now run as federated queries: the keyword query as
before, plus a meaning-only query with a rankingScoreThreshold. A single
hybrid query applies its threshold to both halves, which would also drop
weak keyword matches. The weights are the configured semantic ratio, as
in a hybrid query, and federation removes items both queries find.
The floor is a cosine similarity of 0.3, converted to the score
Meilisearch reports: (1+cos)/2 for full-precision vectors, and the share
of agreeing sign bits for binary-quantized ones, corrected for models
padded with zeros to the canonical 3072 dimensions.
ClosesSilo-Server#3963
Hybrid Meilisearch searches now use federated keyword and meaning-only queries. The meaning-only query has a semantic score floor. Hybrid requests use keyword fallback when federation is unavailable or a hybrid search fails.
Changes: Semantic hybrid search
Layer / File(s)
Summary
Federated queries and semantic score floor internal/catalog/search_meilisearch_client.go, internal/catalog/search_meilisearch_provider.go, internal/catalog/search_meilisearch_hybrid_test.go, internal/catalog/search_provider_test.go
Federated requests separate media keyword and meaning-only queries. Their weights use the configured semantic ratio. The meaning-only query uses a score floor calculated for full-precision and binary-quantized vectors. Tests check request construction and score-floor calculations.
Hybrid routing and keyword fallback internal/catalog/search_meilisearch_provider.go, internal/catalog/search_meilisearch_cursor.go
Hybrid requests use federation across item-type combinations when supported. When federation is unavailable or a hybrid search fails, the request uses keyword search.
sequenceDiagram
participant MeilisearchCursor
participant MeilisearchProvider
participant Meilisearch
MeilisearchCursor->>MeilisearchProvider: route hybrid search
MeilisearchProvider->>Meilisearch: send federated keyword and meaning queries
Meilisearch-->>MeilisearchProvider: return results or search error
alt hybrid search error
MeilisearchProvider->>Meilisearch: retry with keyword-only request
Meilisearch-->>MeilisearchProvider: return keyword results
end
Loading
Suggested reviewers:quick104
Merge Risk: Low · up to 412c7
Meaning-based search now returns only relevant items instead of the whole library. Two edge cases remain: a search that fails partway can return a page with missing or repeated items, and queries with excluded terms such as "-horror" can still return the excluded items. Both are narrow and easy to fix, so the change is mergeable with these follow-ups.
Security architecture risk: Low · up to 412c7
Search access checks and account-bound paging remain in place, including during keyword fallback. No introduced authorization bypass was identified. Compatibility with deployed search-server versions and behavior during live upgrades remain unverified.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The changed flow is reachable through searches eligible for semantics, now including single-media-type requests. In the inspected path, search text influences query content and embedding, while the active index, destination, and credentials remain server-selected. No expansion of those authorities was identified.
Trust Boundaries and Controls
observed — Continuation lookup is account-keyed, and reuse checks the session configuration and a digest covering query, item types, access, structured filters, and grouping. Stored IDs do not grant access: page retrieval applies the current access filter again. These controls are unchanged by the PR.
Resilience and Maintainability Implications
observed — Session storage follows successful ranking and filtering. Redis publication and account eviction execute in one script; the in-memory store uses a mutex and copies ranking IDs. Sessions expire after fifteen minutes and are capped at sixteen per account. Interrupted publication can leave an unused session, but retention remains bounded and expired continuations are rejected.
observed — The process-wide unsupported-federation cache is mutex-protected and normally expires after five minutes. Only capability-shaped failures populate it; index-not-found errors are excluded. Generic hybrid failures cause request-local keyword fallback, and successful offset federation clears the cache. Concurrent updates may affect temporary availability of semantic ranking, not the inspected access controls.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: meaning-based search is fixed so it no longer returns the whole library. The changeset adds a ranking score floor to the meaning query and federates hybrid searches, w…
Linked Issues check
Issue #3963 has one active direct requirement: multi-word hybrid searches must return word matches and semantically similar items, not the whole library. The PR meets it in code. Hybrid searches now r…
Out of Scope Changes check
All changes support the #3963 fix or its direct consequences. The rankingScoreThreshold field on meilisearchFederatedQuery supports the meaning-only query. Federation for all hybrid searches is ne…
Description check
The description states the problem (meaning-based hybrid search returning every library item for multi-word queries), the approach (federated keyword and meaning-only Meilisearch queries with a rankin…
Full details: Title check
Explanation
The title names the main change: meaning-based search is fixed so it no longer returns the whole library. The changeset adds a ranking score floor to the meaning query and federates hybrid searches, which matches the title's intent. The title is specific and uses the conventional fix(search) prefix.
Full details: Linked Issues check
Explanation
Issue #3963 has one active direct requirement: multi-word hybrid searches must return word matches and semantically similar items, not the whole library. The PR meets it in code. Hybrid searches now run as a federated query of a keyword query and a meaning-only query (semanticRatio: 1). Only the meaning query carries rankingScoreThreshold, so unrelated vector matches drop out and keyword matches stay. The threshold derives from a cosine floor of 0.3, with separate conversions for full-precision ((1 + cos) / 2, 0.65) and binary-quantized vectors (agreement share, about 0.597 for 3072 dimensions, scaled for padded dimensions). I checked the quantized arithmetic. At 1536 dimensions the floor is about 0.80, and at 384 dimensions about 0.95. Both match the stated values. The one-word keyword path is unchanged. Tests cover the cursor and offset paths. The PR's end-to-end run with MiniLM reduced 'Model Citizen' from 50 to 6 items, and 'Minority Report' from 50 to 1. The reporter's model (text-embedding-3-large) was not tested. That is validation, not a coding requirement. The issue asks for no change to section order, and the PR makes none.
Full details: Out of Scope Changes check
Explanation
All changes support the #3963 fix or its direct consequences. The rankingScoreThreshold field on meilisearchFederatedQuery supports the meaning-only query. Federation for all hybrid searches is needed because the threshold moved off the hybrid query. The three-query mixed federation keeps the keyword-only episode query, which preserves existing mixed-type behavior. The keyword fallback on federated errors in the offset path matches the existing cursor-path behavior, and it guards the new federated request path. The test changes cover the new request shapes, and search_diagnostics.mode stays hybrid, so no API shape changes. No unrelated change was found in the summarized files.
Full details: Description check
Explanation
The description states the problem (meaning-based hybrid search returning every library item for multi-word queries), the approach (federated keyword and meaning-only Meilisearch queries with a ranking score threshold derived from a 0.3 cosine floor), the fallback changes, risks, and validation evidence. It is directly related to the changeset and is not generic, so it meets the lenient criteria.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Preserve negative terms in the semantic query.
For a query such as space travel -horror, the empty q removes the exclusion from the semantic branch. An item containing horror can then pass the score floor and enter the offset results, although the keyword branch excludes it. Meilisearch 1.56.1 applies negative terms before vector ranking. (raw.githubusercontent.com)
Copy base.Query and base.AttributesToSearchOn into this request. SemanticRatio: 1 already selects semantic-only ranking with a nonempty q. Update the empty-query assertion in search_meilisearch_hybrid_test.go, Line 153. (raw.githubusercontent.com)
The reason will be displayed to describe this comment to others. Learn more.
I checked this against Meilisearch 1.56.1 and sending q would not help. With semanticRatio: 1 the request is SearchKind::SemanticOnly, and prepare_search in crates/meilisearch/src/search/mod.rs never calls search.query(q) for that kind: q is only used to embed the text when no vector is given. So resolve_query sees no query and no negative words are removed. Only the hybrid kind passes q through, which is why the old single hybrid query applied them to its meaning half.
So you are right that -word now narrows only the keyword query, not the meaning matches. I have added that to Risks. The keyword query still excludes the word, and a meaning match has to clear the similarity floor. If maintainers want exclusions applied to meaning matches too, the simplest option is to drop the meaning query when the search has a negative term, which would make those searches keyword-only. I have left it out of this PR.
@blurbery You’re right. I was wrong to suggest copying q: Meilisearch 1.56.1 does not pass it to search.query for SemanticOnly requests.
The exclusion gap remains in the meaning query. I understand your decision to document the risk and leave a change out of this PR. I’m not marking the finding as addressed.
Learnings added
Learnt from: blurbery
Repo: Silo-Server/silo-server PR: 4058
File: internal/catalog/search_meilisearch_provider.go:616-616
Timestamp: 2026-11-13T08:06:10.879Z
Learning: Within repository "Silo-Server/silo-server", only for files matching one of ["internal/catalog/search_meilisearch_provider.go"]: In internal/catalog/search_meilisearch_provider.go, buildFederatedSearchRequest sends a supplied vector with semanticRatio: 1 for the meaning query. In Meilisearch 1.56.1 this selects SemanticOnly, whose prepare_search does not pass q to search.query. Negative terms therefore narrow the keyword query but not the meaning query. Do not suggest copying q into this semantic request as a way to enforce exclusions.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
A hybrid batch that failed part-way through a scan retried keyword search at the hybrid offset and kept the hybrid-ranked items already collected. Keyword ranking differs, so the page could skip or repeat items. The scan now restarts from the first hit in keyword mode.
Review of 86af9c4. I found no defect to fix. One maintainer decision is open: the fixed meaning floor.
The bug is real on main. A hybrid request on main is the keyword request plus vector and hybrid, with no rankingScoreThreshold. A vector search has no cutoff, so scrolling to the end returns every item that has a vector. I checked this against a local Meilisearch 1.56.2, the reporter's version, using hand-made vectors at known cosines. Main's request returned all 56 of 56 documents when one matched by keyword. This branch's federated request kept the keyword match and dropped every meaning match below the floor.
What I checked
TestMeilisearchHybridSearchFloorsOnlyMeaningMatches and TestMeilisearchOffsetHybridSearchFloorsMeaningMatches fail on main and pass here. TestMeilisearchOneWordSearchStaysKeyword passes on both, so it doesn't detect this fix. TestMeilisearchSemanticScoreFloor doesn't build on main because it calls the new function.
Score conversion: Meilisearch's reported scores matched the PR's formulas. For full-precision vectors that is (1 + cos) / 2 exactly. For binary-quantized vectors it is 1 - acos(cos)/π, scaled for zero padding, within the noise quantization adds. I tested 3072-dimension full precision, and binary-quantized models of 3072, 1536 and 384 dimensions padded to 3072. At 384 dimensions the band between "unrelated" and "at the floor" is narrow (about 0.94 to 0.95), but it still separated them.
Paging the federated search 7 hits at a time returned the same items in the same order as one large page, with no repeats. An item that both queries find comes back once.
A semantic ratio of 1 makes the keyword weight 0. Meilisearch accepts that, and keyword matches still come back, after the meaning matches.
Left for the maintainers
Maintainer decision: the 0.3 cosine floor. The maths that turns the floor into a Meilisearch score is right. Whether 0.3 suits real models is unmeasured. My test vectors had no bias in any dimension. Real embeddings can lean one way in some dimensions, which raises sign-bit agreement for unrelated text under binary quantization, the default. Admins can pick any embedding model, and baselines for unrelated text differ by model. If 0.3 is wrong, the result is never worse than main. Too low lets through extra meaning matches, at most the whole library as on main. Too high drops meaning matches and leaves keyword results intact. I'd take 0.3 as the starting value, have the reporter confirm it on their text-embedding-3-large library, and calibrate per model in a follow-up only if that shows a problem.
Exclusions.-word now narrows only the keyword query, as the Risks section says. Silo doesn't document exclusion syntax, and the PostgreSQL provider ignores it, so I don't see this as a blocker.
Ranking changes slightly at semantic ratios other than 0.5. Episode keyword matches now carry the same weight as media keyword matches (1 − ratio) instead of 1. This matches how Meilisearch weighs the keyword half of a hybrid query.
The CodeRabbit and Kody threads about the mid-scan fallback are fixed in 86af9c4. The restart clears the collected items, the offset and the scan count.
Validated features: I couldn't read the validation board, so Validation tasks: none is unconfirmed. Native search, quick search and jellycompat search all reach this code when meaning-based search is on.
User manual: unaffected. No siloserver.org page describes meaning-based search or the semantic share.
Other clients: I agree with N/A. The change is server-side and every client shows what search returns.
Review method: a multi-agent code review, then one cross-provider round on Codex (gpt-6.1-sol). That round raised only the exclusion point above.
Fit: 9/10 · Readiness: 8/10 — conditional. It fixes a core search bug where it starts, in the Meilisearch request, without adding a setting. Readiness waits on the floor decision and the validation-board check.
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
bugSomething isn't workinggoPull requests that update go codeimpact: usabilityCore flow broken or severely blockedpriority: P2Limited scope, workaround exists, or polishsize/L200–499 added + deleted lines (all files); change volume, not priority.
2 participants
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.
Problem
Closes #3963
Related issue: N/A
Validation tasks: none
Other clients: Apple N/A (server change, the app already shows what the search returns); Android N/A (server change, same reason); Roku N/A (server change, same reason)
With Match by meaning as well as words on, every search of two or more words returned every movie and series in the library. One-word searches were fine because they stay keyword-only. Silo sent Meilisearch a hybrid query with no score floor, and the meaning half of a hybrid query ranks every document that has a vector, however unrelated. This change keeps keyword matches as they are and only lets meaning matches through when they're actually similar to the search. It covers the native search (
/api/v2/catalog/queryand the catalog list) and jellycompat search, which go through the same provider.Approach
A hybrid search now runs as a federated Meilisearch search of two queries instead of one hybrid query:
semanticRatio: 1with the query vector) that carries arankingScoreThreshold.I didn't put the threshold on the hybrid query itself because Meilisearch applies a hybrid query's
rankingScoreThresholdto both halves. Keyword scores and vector similarities sit on different scales, so a floor high enough to drop unrelated meaning matches also drops weak keyword matches, such as two words far apart in an overview. With the queries split, every keyword match stays. The federation weights are the configured semantic ratio and one minus it, which is how Meilisearch weighs the two halves inside a hybrid query, and federation keeps one copy of an item both queries find. Mixed episode searches keep their keyword-only episode query.The floor is a cosine similarity of 0.3 between the search and an item, converted to the score Meilisearch reports:
(1 + cos) / 2, so 0.65;1 - acos(cos)/π, so 0.597 for a 3072-dimension model. Silo pads smaller models with zeros to 3072 dimensions, and padded bits always agree, so the floor is scaled by the share of dimensions the model fills (0.80 for 1536 dimensions, 0.95 for 384-dimension MiniLM).0.3 is a starting value. It sits above the cosine unrelated text usually gets from the OpenAI text-embedding-3 models and MiniLM. I checked it end to end with MiniLM (see Evidence) but not with the reporter's text-embedding-3-large, so I'll ask the reporter to try it on their setup.
A federated hybrid search that fails for a reason other than "federation unsupported" now retries as a Meilisearch keyword search in the offset path too, as the cursor path already did, instead of going straight to PostgreSQL. When either fallback happens part-way through a scan, the scan restarts from the first hit in keyword mode, so no hybrid-ranked items or offsets carry over.
No API shape changes.
search_diagnostics.modestill reportshybrid.Validation
internal/catalog(Meilisearch and catalog search), with-race: pass. The new test drivesSearchthrough a fake Meilisearch. It fails on the old routing and passes with this change, and it covers the cursor path, the offset path, and a one-word search staying a plain keyword search.Evidence
Local Silo with Meilisearch 1.56.1, a 50-film test library matched through TMDB, and embeddings from Ollama
all-minilm. Meaning-based search was on with the defaults (binary-quantized vectors, share 0.50, 100% coverage). Both runs used the same database, index and settings; only the Silo binary changed: before0387303d9(main), after412c7d018.The iOS app (silo-apple main
5780c84f, iPhone simulator) shows the same counts on its Search screen: "50 results" before, "6 results" and "2 results" after.Evidence: https://evidence.siloserver.org/r/silo-server/pr-4058/
Risks
-word) now narrow only the keyword query. A meaning-only Meilisearch search never appliesq, so an item containing the excluded word can still come back as a meaning match if it clears the floor. The old single hybrid query applied them to both halves.Checklist
AI Disclosure
Note
Add
rankingScoreThresholdsupport to Meilisearch federated queriesAdds an optional ranking-score threshold field to the federated query payload in search_meilisearch_client.go. It is omitted from JSON when zero, and is intended for the meaning-only search query to filter out low-relevance results. Risk: check the payload marshal logic if other callers of
meilisearchFederatedQueryrely on the exact JSON shape.Macroscope summarized 86af9c4.