-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(default-layout): sortable search results, search phrases, experimental config #3652
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thorough and well explained as always :D
Just found some minor nitpick and open questions for myself.
Testing:
- Seems to work like I would expect
- As I mentioned elsewhere, the bug where preview does lags behind document updates confused my testing a bit. But this is not at all related to this code, and will be fixed when that issue is adressed. I also dont think preview not updating in search result is really a big problem as you typically wont be searching for already opened documents.
- Scores: Unless you know the underlying algorithm, these will probably feel a bit random to people. Title * 10, subtitle * 2, partial match / 2, ect ect. Sorting wise it feels good though!
packages/@sanity/default-layout/src/navbar/search/components/SearchHeader.tsx
Outdated
Show resolved
Hide resolved
packages/@sanity/default-layout/src/navbar/search/components/SortMenu.tsx
Outdated
Show resolved
Hide resolved
offset: pageIndex * SEARCH_LIMIT, | ||
options: { | ||
// Comments prepended to each query for future measurement | ||
comments: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting the comments constructuin and adding some unit tests. Since its invisible to the user, we might not pick up if we break it (for instant if isRecentSearchTerms is changed without thinking about this usage).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love a bit more direction here on specific tests you'd expect!
Right now, comments
in search options has type safety, and there's a test for createSearchQuery that (loosely) covers prepended comments when creating queries
packages/@sanity/default-layout/src/navbar/search/contexts/search/reducer.ts
Outdated
Show resolved
Hide resolved
packages/@sanity/default-layout/src/navbar/search/datastores/recentSearches.ts
Outdated
Show resolved
Hide resolved
packages/@sanity/default-layout/src/navbar/search/hooks/useSearch.ts
Outdated
Show resolved
Hide resolved
packages/@sanity/default-layout/src/navbar/search/utils/isRecentSearchTerms.ts
Outdated
Show resolved
Hide resolved
d654bba
to
6bdbafe
Compare
Thanks @snorrees! Re: scores: I agree! Especially with how search will use preview fields (which can be automatically inferred if you don't have a preview configuration) .... mix in the interplay between |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. I do worry about potentially breaking someone's code by removing the search parts, however.
packages/@sanity/default-layout/src/navbar/search/components/SearchResults.tsx
Outdated
Show resolved
Hide resolved
…ilst open Callbacks for `useClickOutside` were triggering even when the search popover was closed, unnecessarilly resetting the position of the results virtual list.
…n overflow containers receive focus via drag handles
…without valid search terms
…g various interactions: panel unmount, recent search click and on clear
…es during various interactions: panel unmount, recent search click and on clear" This reverts commit 151241c.
…until both popover + dialog components have mounted
…e search specs (plural) to be consistent with typing
…s display a tooltip even on zero-score hits
…f search results when ordering by custom fields
…nd GROQ comments in createSearchQuery, group tests
… define scoped weightedSearch function in default-layout
…nd selectors, move into utils
…code to be strictNullChecks-friendly
…ts to be a little more explicit
… search as a memoized function
…r for search results
18d84fa
to
59a9829
Compare
…mental config (#3652) This commit updates search with the following features: - Order search results by relevance, created and last updated date. - Search for documents containing an exact phrase by wrapping text inside double quotes. - Use the experimental config `__experimental_omnisearch_visibility` to hide documents from global search. - Display relevance scores in search results via a debug flag (`#_debug_search_score`) It comes with the following fixes: - Fixes an issue where the scroll position of search results wasn’t being correctly retained in some instances. - Fixes an issue where search would cause the studio to crash if Local Storage is unavailable.
…onfig (#3764) This commit is a V3 port of #3652 It updates search with the following features: - Order search results by relevance, created and last updated date. - Search for documents containing an exact phrase by wrapping text inside double quotes. - Use the experimental config `__experimental_omnisearch_visibility` to hide documents from global search. - Display relevance scores in search results via a debug flag (`#_debug_search_score`)
Description
Features
__experimental_omnisearch_visibility: true
to your document schemas to hide them from omnisearch. Perfect for hiding workflow-related documents or configuration singletons that don’t need to be accessed frequently.#_debug_search_score
)Bug fixes
What to review
Notable changes
Taking cues from the reference and cross dataset reference input components – the function to generate weighted search is now colocated within
default-layout
rather than being an export of@sanity/base/search
@sanity/base/_internal
Given thatpart:@sanity/base/search
andpart:@sanity/base/search/weighted
are not being used anywhere else in the studio, they’ve been removedLogic for how we extract search queries and calculate scores has been expanded to accommodate searching for phrases in wrapped quotes:
A few more comments are now attached with each search query for measurement. Full example:
In the above example,
findability-recent-search:4
indicates that this was the 5th item clicked in recent searches. All these comments will be removed once client-side instrumentation is in place.In the test studio: a debug schema
experimentalOmnisearchVisibilityTest
has been added. These documents have__experimental_omnisearch_visibility:false
and won’t appear in omnisearch.Sorting by relevance will now sort by
_updatedAt desc
in GROQ before applying scoring on the client, leaning towards more recent documents in general. Previously, omnisearch was sorting on_id asc
._id asc
.Notable refactoring:
createWeightedSearch
signature slightly, and have moved more into theSearchOptions
typedefault-layout
(mocha
,nyc
) and it now usesreact-testing-library
.default-layout
was also added to the root leveljest.config.js
@sanity/base
are now colocated and have been expanded on slightly.strictNullChecks: true
.Things to test
"winnie-the-pooh"
vswinnie-the-pooh
"go, team. go!"
vsgo, team. go!
Notes for release
Highlights
Search updates
Bugfixes