Skip to content
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(core): add Text Search API search strategy #5785

Merged
merged 46 commits into from
Mar 5, 2024

Conversation

juice49
Copy link
Contributor

@juice49 juice49 commented Feb 19, 2024

Description

This branch adds the option to use the Text Search API to power Studio search, rather than the existing GROQ query search strategy.

This can be enabled in Studio projects by setting the search.unstable_enableNewSearch configuration option to true. When enabled, global search, reference search, and Cross Dataset Reference search will all use the Text Search API.

In addition, we've removed the unused offset-based pagination from the global search UI, instead implementing infinite scrolling using cursor-based pagination.

What to review

  • When search.unstable_enableNewSearch is not enabled, the existing search strategy will be used, and results should be unchanged.
  • When search.unstable_enableNewSearch is enabled, search queries will use the Text Search API. Filter the request log by textsearch to isolate these requests. It's expected that search results will not match those provided by the existing search strategy at the moment.
  • This change affects global search, reference search, and Cross Dataset Reference search.

Testing

  • The global search reducer test (packages/sanity/src/core/studio/components/navbar/search/contexts/search/reducer.test.ts) has been updated to test pagination/infinite scrolling for cursor-based pagination.

Notes for release

Draft notes - this has not been widely enabled for datasets yet, so is not ready to be announced.
This release adds support for an experimental new Studio search strategy. After enabling this strategy, global search, reference search, and Cross Dataset Reference search will use a new Sanity HTTP API dedicated to performing search. The new search strategy is more efficient, and supports token negation by adding a `-` prefix.

Please note the new search strategy doesn't yet provide functional parity with the existing search strategy. Notably, field weighting, prefix search, and Portable Text search are absent. You may experience other inconsistencies or unexpected behaviour while this feature is in use.

The new search strategy can be enabled in Studio projects by setting the search.unstable_enableNewSearch configuration option to true. While we work to make this the default search strategy, we welcome any feedback you have!

Copy link

vercel bot commented Feb 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Mar 5, 2024 2:36pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2024 2:36pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Mar 5, 2024 2:36pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Feb 29, 2024

Component Testing Report Updated Mar 5, 2024 2:38 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 37s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 12s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 30s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 0s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 1s 18 0 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 19s 9 0 0

Copy link
Contributor

@jtpetty jtpetty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@juice49 juice49 added this pull request to the merge queue Mar 5, 2024
Merged via the queue into next with commit 49fa240 Mar 5, 2024
40 checks passed
@juice49 juice49 deleted the feat/adopt-text-search-api branch March 5, 2024 15:06
juice49 added a commit that referenced this pull request Mar 13, 2024
* feat(core): add Text Search API search strategy

* feat(core): support multiple search strategies in `createSearch` function

* feat(core): use generic `createSearch` function for navbar search

* feat(core): use generic `createSearch` function for reference search

* feat(structure): very unsound prototype of Text Search API strategy for document lists

* feat(core): export Text Search API types

* feat(core): add type filtering to Text Search API request

* feat(core): remove unused search weighting for Text Search API search strategy

* feat(core): support filtering in Text Search API strategy

* refactor(core): specialise `createSearchQuery` function for Text Search API search strategy

* feat(core): add `TextSearchParams.params` type

* fix(core): allow `TextSearchParams.params` to include any single or array of primitives

* refactor(core): return `TextSearchParams` directly

* feat(core): add limit to Text Search API search strategy

* fix(core): allow non-weighted search hit

* refactor(core): remove unused function

* fix(core): allow non-weighted search hit

* refactor(core): remove unused function

* feat(core): scaffold hybrid search strategy

* refactor(core): rename for clarity

* chore(core): remove irrelevant comment

* feat(core): add `search.__experimental_strategy` option for controlling search strategy

* feat(test-studio): enable Text Search API search strategy

* feat: implement hybrid approach (messy)

* refactor(core): rename for clarity

* feat(core): add `useDocumentSearch` stub

* feat(core): prototype Text Search API pagination with global search

* feat(core): support new result data shape in weighted search strategy

* refactor(core): refine search result type

* fix(core): allow reference search to work with new data shape

* refactor(core): improve search strategy types

* refactor(core): improve search strategy types

* refactor: remove hybrid search and clean up

* refactor(core): rename binding

* refactor(core): remove unused offset-based pagination, fix pagination, handle next cursor in `SearchRequestComplete` action

* fix(core): use new data shape

* test(core): remove nonexistent option

* fix(core): deduplicate search results

* refactor(core): remove unused `useDocumentSearch` hook prototype

* test(core): global search pagination

* test(core): add assertion

* refactor(core): add type parameter for Text Search API hit attributes

* refactor(core): remove unused offset

* refactor(core): remove unused search offset handling

* feat(core): increase default search limit

* chore(core): add clarification

---------

Co-authored-by: Rico Kahler <[email protected]>
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.

4 participants