feat(core): use schema preview selection for search#12925
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📦 Bundle Stats —
|
| Metric | Value | vs main (163d020) | vs v5.30.0 |
|---|---|---|---|
| Internal (raw) | 4.55 MB | +2.9 KB, +0.1% | +3.3 KB, +0.1% |
| Internal (gzip) | 1.05 MB | +568 B, +0.1% | +659 B, +0.1% |
| Bundled (raw) | 12.24 MB | +2.9 KB, +0.0% | -91.6 KB, -0.7% |
| Bundled (gzip) | 2.75 MB | +549 B, +0.0% | -19.7 KB, -0.7% |
| Import time | 1.58s | -16ms, -1.0% | +53ms, +3.5% |
bin:sanity
| Metric | Value | vs main (163d020) | vs v5.30.0 |
|---|---|---|---|
| Internal (raw) | 7.1 KB | - | - |
| Internal (gzip) | 2.9 KB | - | - |
| Bundled (raw) | 7.1 KB | - | - |
| Bundled (gzip) | 2.8 KB | - | - |
| Import time | 5ms | -0ms, -1.9% | +0ms, +6.3% |
🗺️ View treemap · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
✅ E2E Tests🟢 199 passed • 🟡 7 flaky • (⚪ 90 skipped) • view full report • view run |
📚 TypeDoc Generation Result✅ TypeDoc generated successfully!
The TypeDoc JSON file has been generated and validated. All documentation scripts completed successfully. |
⚡️ Editor Performance ReportUpdated Wed, 03 Jun 2026 14:18:06 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
There was a problem hiding this comment.
Pull request overview
This PR fixes search behavior where fields shown in list previews via reference traversal (eg subtitle: 'author.name') were displayed but not searchable, by deriving weights for preview select paths that traverse references and compiling those dotted paths into dereferenced GROQ (eg author->name) when building search queries (weighted + groq2024 strategies).
Changes:
- Extend weight derivation to include preview
selectpaths that traverse references (so they become searchable/boostable). - Compile preview-derived dotted paths against the schema into dereferenced GROQ field expressions when generating queries.
- Add targeted tests covering reference-traversing preview selections for both search strategies.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/sanity/src/core/search/weighted/createSearchQuery.ts | Compiles preview-selected dotted paths against schema so reference traversals become -> derefs in weighted search queries. |
| packages/sanity/src/core/search/weighted/createSearchQuery.test.ts | Adds regression test asserting reference preview paths become searchable and number fields don’t become constraints. |
| packages/sanity/src/core/search/groq2024/createSearchQuery.ts | Compiles paths used for scoring/boosting so preview-derived reference traversals are boosted via dereferenced GROQ. |
| packages/sanity/src/core/search/groq2024/createSearchQuery.test.ts | Adds regression test asserting reference preview paths are boosted and non-searchable preview fields are excluded. |
| packages/sanity/src/core/search/common/deriveSearchWeightsFromType2024.ts | Incorporates preview-selection reference traversal weights into the 2024 weight derivation flow. |
| packages/sanity/src/core/search/common/deriveSearchWeightsFromType.ts | Adds getPreviewSelectionPathWeights + reference-following leaf resolution so preview select paths behind references get search weights. |
| packages/sanity/src/core/search/common/tests/deriveSearchWeightsFromType.test.ts | Adds tests for reference preview selection weight derivation and for getPreviewSelectionPathWeights. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description
Fixes #4775
Fields shown in a list item via a reference (e.g.
subtitle: 'author.name') were visible in previews but not searchable — issue #4775. Weight derivation skips references: ingetLeafWeights(deriveSearchWeightsFromType.ts) the object-field recursion is gated by!ignoredBuiltInObjectTypes.includes(t.name), andreferenceis inignoredBuiltInObjectTypes, soauthor.namenever became a search path — and the query never dereferenced it either.Now preview
selectpaths that traverse references are resolved to their searchable leaf and compiled toauthor->namein the query (reusing the samecompileFieldPaththat orderings use).Example in books, now search by author.name returns the results because
author.nameandauthor.bestFriend.nameis part of the book previewselecthttps://github.com/sanity-io/sanity/blob/main/dev/test-studio/schema/book.ts#L169Screen.Recording.2026-06-03.at.15.56.45.mov
What to review
Testing
Notes for release