Stamp _isCardInstance and cardTitle into file search docs during indexing#5395
Draft
FadhlanR wants to merge 1 commit into
Draft
Stamp _isCardInstance and cardTitle into file search docs during indexing#5395FadhlanR wants to merge 1 commit into
FadhlanR wants to merge 1 commit into
Conversation
…xing The fused visit already knows whether a file is a card-instance .json (it dual-indexes those with an instance row plus a file row) but threw that fact away before the file indexer ran. Thread it through as FileIndexerOptions.isCardInstance and stamp `_isCardInstance: true` into the file row's search doc — on the dependency-error entry too, so card .json files whose card is in an error state stay out of file search. Also alias the file name under `cardTitle` so mixed cards+files queries can substring-match and A-Z sort file rows with the same search-doc key card docs use. Pre-existing index rows lack both keys until their realm reindexes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
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.
What
Every realm file gets a
type='file'index row, and a card-instance.jsonis dual-indexed (aninstancerow plus afilerow). The fused visit computes "is this a card instance" at index time (parsedCardResource) but the file indexer never learned it. This PR threads that fact through toperformFileIndexingand stamps two synthetic keys into the file row'ssearch_doc:_isCardInstance: true— marks thefilerow of a dual-indexed card-instance.jsonso a mixed cards+files search can exclude it (the card already appears via itsinstancerow). Stamped on the dependency-error entry too, so a card.jsonwhose card is in an error state stays out of file search. Only stamped when true; plain file docs don't carry the key. Added to the searchable-parity ignore set alongside_cardType.cardTitle— the file's name aliased under the key card docs use (CardDef's title field is namedcardTitle). The search sheet's term filter substring-matches viacontains: {cardTitle}(full-textmatchesonly matches whole words) and A-Z sort compiles tosearch_doc->>'cardTitle'with NULLS LAST, so without the alias files never prefix-match and always sink below every card in a mixed result set. It is not a claim that the file is a card.Both keys are stamped generically in
file-indexer.ts; nopackages/baseor query-engine changes.Rollout caveat
Pre-existing index rows lack both keys until their realm reindexes — until then, card-instance
.jsonfiles will linger in file search and files will sort/match degraded, per realm. Forced reindex vs. natural cadence is a ship-time decision for the downstream mixed-search work.Testing
Extended
packages/realm-server/tests/indexing-test.ts:.jsonfixture carries_isCardInstance: trueandcardTitle= file namecardTitle= file name and no_isCardInstancekey🤖 Generated with Claude Code