Search options to customize the search behavior.
The type of id being indexed.
BM25+ algorithm parameters. Customizing these is almost never necessary, and fine-tuning them requires an understanding of the BM25 scoring model. In most cases, it is best to omit this option to use defaults, and instead use boosting to tweak scoring for specific use cases.
Key-value object of field names to boosting values. By default, fields are assigned a boosting factor of 1. If one assigns to a field a boosting value of 2, a result that matches the query in that field is assigned a score twice as high as a result matching the query in another field, all else being equal.
Function to calculate a boost factor for documents. It takes as arguments the document ID, and a term that matches the search in that document, and the value of the stored fields for the document (if any). It should return a boosting factor: a number higher than 1 increases the computed score, a number lower than 1 decreases the score, and a falsy value skips the search result completely.
OptionalstoredFields: Record<string, unknown>
The operand to combine partial results for each term. By default it is "OR", so results matching any of the search terms are returned by a search. If "AND" is given, only results matching all the search terms are returned by a search.
Names of the fields to search in. If omitted, all fields are searched.
Function used to filter search results, for example on the basis of stored fields. It takes as argument each search result and should return a boolean to indicate if the result should be kept or not.
Controls whether to perform fuzzy search. It can be a simple boolean, or a number, or a function.
If a boolean is given, fuzzy search with a default fuzziness parameter is performed if true.
If a number higher or equal to 1 is given, fuzzy search is performed, with a maximum edit distance (Levenshtein) equal to the number.
If a number between 0 and 1 is given, fuzzy search is performed within a
maximum edit distance corresponding to that fraction of the term length,
approximated to the nearest integer. For example, 0.2 would mean an edit
distance of 20% of the term length, so 1 character in a 5-characters term.
The calculated fuzziness value is limited by the
maxFuzzy option, to
prevent slowdown for very long queries.
If a function is passed, the function is called upon search with a search term, a positional index of that term in the tokenized search query, and the tokenized search query. It should return a boolean or a number, with the meaning documented above.
Controls the maximum fuzziness when using a fractional fuzzy value. This is set to 6 by default. Very high edit distances usually don't produce meaningful results, but can excessively impact search performance.
Controls whether to perform prefix search. It can be a simple boolean, or a function.
If a boolean is passed, prefix search is performed if true.
If a function is passed, it is called upon search with a search term, the positional index of that search term in the tokenized search query, and the tokenized search query. The function should return a boolean to indicate whether to perform prefix search for that search term.
Function to process or normalize terms in the search query. By default, the same term processor used for indexing is used also for search.
Function to tokenize the search query. By default, the same tokenizer used for indexing is used also for search.
Relative weights to assign to prefix search results and fuzzy search results. Exact matches are assigned a weight of 1.
Generated using TypeDoc