Skip to content

Commit

Permalink
feat: add groq2024 search strategy option
Browse files Browse the repository at this point in the history
  • Loading branch information
juice49 committed Nov 8, 2024
1 parent 65bae66 commit 3c83f9a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@sanity/types/src/search/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @public
*/
export const searchStrategies = ['groqLegacy', 'textSearch'] as const
export const searchStrategies = ['groqLegacy', 'textSearch', 'groq2024'] as const

/**
* @public
Expand Down
2 changes: 2 additions & 0 deletions packages/sanity/src/core/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ export interface PluginOptions {
* - `"groqLegacy"` (default): Use client-side tokenization and schema introspection to search
* using the GROQ Query API.
* - `"textSearch"` (deprecated): Perform full text searching using the Text Search API.
* - `"groq2024"`: Perform full text searching using the GROQ Query API and its new
* `text::matchQuery` function.
*/
strategy?: SearchStrategy

Expand Down
1 change: 1 addition & 0 deletions packages/sanity/src/core/search/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {createWeightedSearch} from './weighted'
const searchStrategies = {
groqLegacy: createWeightedSearch,
textSearch: createTextSearch,
groq2024: createWeightedSearch,
} satisfies Record<SearchStrategy, SearchStrategyFactory<TextSearchResults | WeightedSearchResults>>

const DEFAULT_SEARCH_STRATEGY: SearchStrategy = 'groqLegacy'
Expand Down

0 comments on commit 3c83f9a

Please sign in to comment.