From 3c83f9a173d7c3737347d11e90580af6bccbc721 Mon Sep 17 00:00:00 2001 From: Ash Date: Fri, 8 Nov 2024 11:34:15 +0000 Subject: [PATCH] feat: add `groq2024` search strategy option --- packages/@sanity/types/src/search/types.ts | 2 +- packages/sanity/src/core/config/types.ts | 2 ++ packages/sanity/src/core/search/search.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/@sanity/types/src/search/types.ts b/packages/@sanity/types/src/search/types.ts index 6025fc16dc5..1eacc85da7d 100644 --- a/packages/@sanity/types/src/search/types.ts +++ b/packages/@sanity/types/src/search/types.ts @@ -1,7 +1,7 @@ /** * @public */ -export const searchStrategies = ['groqLegacy', 'textSearch'] as const +export const searchStrategies = ['groqLegacy', 'textSearch', 'groq2024'] as const /** * @public diff --git a/packages/sanity/src/core/config/types.ts b/packages/sanity/src/core/config/types.ts index 4852fd8b7d2..92a063e6162 100644 --- a/packages/sanity/src/core/config/types.ts +++ b/packages/sanity/src/core/config/types.ts @@ -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 diff --git a/packages/sanity/src/core/search/search.ts b/packages/sanity/src/core/search/search.ts index a877c4c20e3..393c403d900 100644 --- a/packages/sanity/src/core/search/search.ts +++ b/packages/sanity/src/core/search/search.ts @@ -11,6 +11,7 @@ import {createWeightedSearch} from './weighted' const searchStrategies = { groqLegacy: createWeightedSearch, textSearch: createTextSearch, + groq2024: createWeightedSearch, } satisfies Record> const DEFAULT_SEARCH_STRATEGY: SearchStrategy = 'groqLegacy'