ObjectSearchOptions
Options for searchObjects(). Extends KeySearchOptions (the
SearchOptions fields plus scoreMode and matchMode) with key
configuration.
Note: includePositions has no effect for multi-key search — match positions
are per-key and are not merged, so results have no positions/matchType.
All other fields (maxResults, minScore, isCaseSensitive, returnAllOnEmpty,
scoreMode, matchMode) apply.
Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T |
unknown |
Properties
Section titled “Properties”| Property | Type | Description | Inherited from |
|---|---|---|---|
includePositions? |
boolean |
Accepted for compatibility with SearchOptions, but has no effect: multi-key results have no match positions. |
KeySearchOptions.includePositions |
isCaseSensitive? |
boolean |
If true, matching is case-sensitive. When false or omitted, matching is smart case: case-insensitive while the query is all lower-case, and case-sensitive once it contains an upper-case letter. false does not force case-insensitive matching; lower-case the query for that. |
KeySearchOptions.isCaseSensitive |
keys |
readonly (IsWide<NonNullable<T>> extends true ? string : { [S in `${number}`]: S | `${S}.${IsWide<Step<NonNullable<(…)>, S>> extends true ? string : { [S in string]: (…) | (…) }[SegmentOf<Step<(…), (…)>>]}` }[SegmentOf<NonNullable<T>>] | KeyConfig<T>)[] |
- | - |
matchMode? |
KeyMatchMode |
How the query is matched against the keys of an item: - 'perKey' (default): every key is matched against the whole query, like search() matches an item. A key scores 0 unless it matches every term of the query and none of its !term exclusions. - 'crossKey': every term is matched against the keys on its own, so the terms may match different keys: 'john tokyo' finds an item whose name is “John Smith” and whose city is “Tokyo”. Every term must match at least one key, and a !term matching any key excludes the item. A key’s score (keyScores) is the share of the query it matches: the scores of the terms it matches, each counting in proportion to the score of a perfect match of the term (which grows with its length), so a key matching every term perfectly scores 1. scoreMode combines these key scores: 'weighted' as sum(weight * keyScore) / sum(weight), as in 'perKey' mode; 'matched' as sum(weight * keyScore) / sum(weight * coverage), where a key’s coverage is the share of the query made up by the terms it matches (in 'perKey' mode, 1 for a key that matches and 0 otherwise); 'max' by taking each term’s score on the key it matches best. In 'max' mode, an item whose every term matches some key perfectly scores 1. In 'matched' mode, only an item whose every term matches perfectly each key it matches scores 1: a term that also matches another key partially lowers the score, so 'john tokyo' scores 0.89 on an item whose name is “John Smith”, whose city is “Tokyo” and whose email “jtokyo@example.com” matches tokyo partially. Only keys with a positive weight take part in either mode; keys whose weight is 0 still get keyScores. For a query of a single term without exclusions, both modes return the same results. Any other value throws an InvalidArg error. |
KeySearchOptions.matchMode |
maxResults? |
number |
Maximum number of results to return: a non-negative integer, or Infinity for no limit. NaN, negative and fractional values throw. |
KeySearchOptions.maxResults |
minScore? |
number |
Minimum combined score (0.0-1.0, see scoreMode) to include in results. NaN throws. |
KeySearchOptions.minScore |
returnAllOnEmpty? |
boolean |
If true, return all items when the query has no search term: empty, whitespace-only, or only query syntax such as ^ or !. Every item then scores 1, in every scoreMode, and they come in index order. Default is false. |
KeySearchOptions.returnAllOnEmpty |
scoreMode? |
KeyScoreMode |
How the per-key scores (keyScores) of an item are combined into its score. Only keys with a positive weight take part: - 'weighted' (default): the weighted mean over all keys, sum(weight * keyScore) / sum(weight). A key that does not match counts as 0, so an exact match on one key out of several scores only that key’s share of the total weight. - 'matched': the weighted mean over the keys that match (keyScore > 0) only. An item whose only matching key matches exactly scores 1. - 'max': the highest score of any key. Weights then only select the keys that take part (weight > 0). keyScores are the same in every mode; minScore and maxResults apply to the combined score. Equal scores are ordered by the UTF-8 byte length of the best-matching key’s text (the key contributing most to the score: highest weight * keyScore, or highest keyScore in 'max' mode; the first one on a tie), then by index. Any other value throws an InvalidArg error. With matchMode: 'crossKey', 'matched' counts the weight of each key in proportion to the share of the query it matches, and 'max' scores each term by the key it matches best (see matchMode). |
KeySearchOptions.scoreMode |