@@ -20,6 +20,7 @@ import {
2020 type LiveSearchProviderId ,
2121} from '@/lib/sim-search/live/provider-catalog'
2222import { readSlack , searchSlack } from '@/lib/sim-search/live/slack'
23+ import type { AnyTermFallbackOptions } from '@/lib/sim-search/live/term-fallback'
2324import type {
2425 NativeClient ,
2526 NativeDocument ,
@@ -46,13 +47,12 @@ interface NativeQueryGuide {
4647
4748interface NativeProvider {
4849 guide : NativeQueryGuide
49- /** Plain queries must contain every word, so an underfilled search retries with any term. */
50- requiresEveryTerm ?: true
5150 /**
52- * The any-term retry ranks items sharing just a couple of common words alongside close matches,
53- * so its partial matches must contain at least half the query's terms.
51+ * Plain queries must contain every word, so an underfilled search retries with any term.
52+ * `requireHalfTheTerms` is for a provider whose any-term query ranks items sharing just a couple
53+ * of common words alongside close matches.
5454 */
55- partialMatchesNeedHalfTheTerms ?: true
55+ anyTermRetry ?: AnyTermFallbackOptions
5656 /**
5757 * Full text for a search preview, for providers whose search returns only an excerpt or
5858 * metadata. At most one request; undefined for kinds without a cheap text form.
@@ -181,8 +181,7 @@ export const LIVE_SEARCH_PROVIDERS = {
181181 avoid :
182182 'JQL with only an ORDER BY clause (Jira rejects unbounded queries), and identifying users other than currentUser() by display name or email; use their account ID.' ,
183183 } ,
184- requiresEveryTerm : true ,
185- partialMatchesNeedHalfTheTerms : true ,
184+ anyTermRetry : { requireHalfTheTerms : true } ,
186185 search : ( client , input ) => searchAtlassian ( client , 'jira' , input ) ,
187186 read : ( client , reference ) => readAtlassian ( client , 'jira' , reference . id , reference . container ) ,
188187 } ,
@@ -196,7 +195,7 @@ export const LIVE_SEARCH_PROVIDERS = {
196195 avoid :
197196 'starting the query with a negative clause (NOT, !=, !~ or NOT IN), which CQL rejects; lead with a positive clause such as type IN (page, blogpost).' ,
198197 } ,
199- requiresEveryTerm : true ,
198+ anyTermRetry : { requireHalfTheTerms : false } ,
200199 previewText : previewConfluence ,
201200 search : ( client , input ) => searchAtlassian ( client , 'confluence' , input ) ,
202201 read : ( client , reference ) =>
@@ -319,18 +318,13 @@ export function searchNativeProvider(
319318 return adapter . search ( client , input )
320319}
321320
322- /** True when the provider's plain-text search matches only items containing every query word. */
323- export function requiresEveryTerm ( provider : LiveSearchProviderId ) : boolean {
324- const adapter = LIVE_SEARCH_PROVIDERS [ provider ]
325- return 'requiresEveryTerm' in adapter && adapter . requiresEveryTerm === true
326- }
327-
328- /** True when the provider's partial matches must contain at least half the query's terms. */
329- export function partialMatchesNeedHalfTheTerms ( provider : LiveSearchProviderId ) : boolean {
321+ /**
322+ * How the provider retries an underfilled plain search with any term; undefined when its
323+ * plain-text search does not require every query word.
324+ */
325+ export function anyTermRetry ( provider : LiveSearchProviderId ) : AnyTermFallbackOptions | undefined {
330326 const adapter = LIVE_SEARCH_PROVIDERS [ provider ]
331- return (
332- 'partialMatchesNeedHalfTheTerms' in adapter && adapter . partialMatchesNeedHalfTheTerms === true
333- )
327+ return 'anyTermRetry' in adapter ? adapter . anyTermRetry : undefined
334328}
335329
336330/**
0 commit comments