From ba27885fc586fa0e88578e6f3b537e864248fd49 Mon Sep 17 00:00:00 2001 From: Robin Pyon Date: Fri, 14 Jul 2023 11:34:29 +0100 Subject: [PATCH] fixup! fix(core): export all weighted search functions and types --- packages/@sanity/base/src/_exports/_internal.ts | 2 +- packages/@sanity/base/src/search/weighted/applyWeights.ts | 4 ++-- .../@sanity/base/src/search/weighted/createSearchQuery.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@sanity/base/src/_exports/_internal.ts b/packages/@sanity/base/src/_exports/_internal.ts index 6f317047a2f..2791d9550c4 100644 --- a/packages/@sanity/base/src/_exports/_internal.ts +++ b/packages/@sanity/base/src/_exports/_internal.ts @@ -15,7 +15,7 @@ export type {DocumentAvailability} from '../preview/types' export {AvailabilityReason} from '../preview/types' export {getSearchableTypes} from '../search/common/utils' -export {createWeightedSearch} from '../search/weighted/createWeightedSearch' +export {createSearchQuery, createWeightedSearch} from '../search/weighted' export type {WeightedHit} from '../search/weighted/types' export {createHookFromObservableFactory} from '../util/createHookFromObservableFactory' diff --git a/packages/@sanity/base/src/search/weighted/applyWeights.ts b/packages/@sanity/base/src/search/weighted/applyWeights.ts index b91d79baef9..db85391164e 100644 --- a/packages/@sanity/base/src/search/weighted/applyWeights.ts +++ b/packages/@sanity/base/src/search/weighted/applyWeights.ts @@ -84,7 +84,7 @@ export function applyWeights( } /** - * Generate a sccore on the total number of matching characters. + * For phrases: score on the total number of matching characters. * E.g. given the phrases ["the fox", "of london"] for the target value "the wily fox of london" * * - "the fox" isn't included in the target value (score: 0) @@ -114,7 +114,7 @@ export function calculatePhraseScore(uniqueSearchPhrases: string[], value: strin } /** - * Generate a score on the total number of matching characters. + * For words: score on the total number of matching words. * E.g. given the terms ["bar", "fo"] for the target value "food bar". * * - "fo" is included in the target value, and 2 out of 7 non-whitespace characters match (score: 2/7) diff --git a/packages/@sanity/base/src/search/weighted/createSearchQuery.ts b/packages/@sanity/base/src/search/weighted/createSearchQuery.ts index c0c8a0fc362..8b2714a6b39 100644 --- a/packages/@sanity/base/src/search/weighted/createSearchQuery.ts +++ b/packages/@sanity/base/src/search/weighted/createSearchQuery.ts @@ -1,5 +1,5 @@ -import {ExperimentalSearchPath} from '@sanity/types' import {compact, flatten, flow, toLower, trim, union, uniq, words} from 'lodash' +import {ExperimentalSearchPath} from '../../../../types' import {joinPath} from '../../util/searchUtils' import {tokenize} from '../common/tokenize' import type {