Skip to content

Stamp _isCardInstance and cardTitle into file search docs during indexing#5395

Draft
FadhlanR wants to merge 1 commit into
mainfrom
cs-11774-cardtitle-justification
Draft

Stamp _isCardInstance and cardTitle into file search docs during indexing#5395
FadhlanR wants to merge 1 commit into
mainfrom
cs-11774-cardtitle-justification

Conversation

@FadhlanR

@FadhlanR FadhlanR commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Every realm file gets a type='file' index row, and a card-instance .json is dual-indexed (an instance row plus a file row). 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 to performFileIndexing and stamps two synthetic keys into the file row's search_doc:

  • _isCardInstance: true — marks the file row of a dual-indexed card-instance .json so a mixed cards+files search can exclude it (the card already appears via its instance row). Stamped on the dependency-error entry too, so a card .json whose 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 named cardTitle). The search sheet's term filter substring-matches via contains: {cardTitle} (full-text matches only matches whole words) and A-Z sort compiles to search_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; no packages/base or query-engine changes.

Rollout caveat

Pre-existing index rows lack both keys until their realm reindexes — until then, card-instance .json files 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:

  • the file entry for a card-instance .json fixture carries _isCardInstance: true and cardTitle = file name
  • a plain text file's search doc carries cardTitle = file name and no _isCardInstance key

🤖 Generated with Claude Code

…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>
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Host Test Results

  1 files    1 suites   16m 34s ⏱️
542 tests 542 ✅ 0 💤 0 ❌
543 runs  543 ✅ 0 💤 0 ❌

Results for commit d3f4317.

Realm Server Test Results

    1 files      1 suites   10m 3s ⏱️
1 674 tests 1 674 ✅ 0 💤 0 ❌
1 753 runs  1 753 ✅ 0 💤 0 ❌

Results for commit d3f4317.

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.

1 participant