Skip to content
On this page

FlexSearch is highly customizable. Make use of the right options can really improve your results as well as memory economy and query time. ## Index Options

OptionValuesDescriptionDefault
preset"memory"
"performance"
"match"
"score"
"default"
The configuration profile as a shortcut or as a base for your custom settings."default"
tokenize"strict"
"forward"
"reverse"
"full"
The indexing mode (tokenizer).

Choose one of the built-ins or pass a custom tokenizer function.
"strict"
cacheBoolean
Number
Enable/Disable and/or set capacity of cached entries.

When passing a number as a limit the cache automatically balance stored entries related to their popularity.

Note: When just using "true" the cache has no limits and growth unbounded.
false
resolutionNumberSets the scoring resolution (default: 9).9
contextBoolean
Context Options
Enable/Disable contextual indexing. When passing "true" as value it will take the default values for the context.false
optimizeBooleanWhen enabled it uses a memory-optimized stack flow for the index.true
boostfunction(arr, str, int) => floatA custom boost function used when indexing contents to the index. The function has this signature: Function(words[], term, index) => Float. It has 3 parameters where you get an array of all words, the current term and the current index where the term is placed in the word array. You can apply your own calculation e.g. the occurrences of a term and return this factor (<1 means relevance is lowered, >1 means relevance is increased).

Note: this feature is currently limited by using the tokenizer "strict" only.
null
Language-specific Options and Encoding:
charsetCharset Payload
String (key)
Provide a custom charset payload or pass one of the keys of built-in charsets."latin"
languageLanguage Payload
String (key)
Provide a custom language payload or pass in language shorthand flag (ISO-3166) of built-in languages.null
encodefalse
"default"
"simple"
"balance"
"advanced"
"extra"
function(str) => [words]
The encoding type.

Choose one of the built-ins or pass a custom encoding function.
"default"
stemmerfalse
String
Function
false
filterfalse
String
Function
false
matcherfalse
String
Function
false
Additional Options for Document Indexes:
workerBooleanEnable/Disable and set count of running worker threads.false
documentDocument DescriptorIncludes definitions for the document index and storage.

Context Options

OptionValuesDescriptionDefault
resolutionNumberSets the scoring resolution for the context (default: 1).1
depthfalse
Number
Enable/Disable contextual indexing and also sets contextual distance of relevance. Depth is the maximum number of words/tokens away a term to be considered as relevant.1
bidirectionalBooleanSets the scoring resolution (default: 9).true

Document Options

OptionValuesDescriptionDefault
idString"id""
tagfalse
String
"tag"
indexString
Array<String>
Array<Object>
storeBoolean
String
Array<String>
false

Charset Options

OptionValuesDescriptionDefault
splitfalse
RegExp
String
The rule to split words when using non-custom tokenizer (built-ins e.g. "forward"). Use a string/char or use a regular expression (default: /\W+/)./[\W_]+/
rtlBooleanEnables Right-To-Left encoding.false
encodefunction(str) => [words]The custom encoding function./lang/latin/default.js

Language Options

OptionValuesDescription
stemmerfalse
String
Function
Disable or pass in language shorthand flag (ISO-3166) or a custom object.
filterfalse
String
Function
Disable or pass in language shorthand flag (ISO-3166) or a custom array.
matcherfalse
String
Function
Disable or pass in language shorthand flag (ISO-3166) or a custom array.

Search Options

OptionValuesDescriptionDefault
limitnumberSets the limit of results.100
offsetnumberApply offset (skip items).0
suggestBooleanEnables suggestions in results.false

Document Search Options - Additionally, to the Index search options above.

OptionValuesDescriptionDefault
indexString
Array<String>
Array<Object>
Sets the document fields which should be searched. When no field is set, all fields will be searched. Custom options per field are also supported.
tagString
Array<String>
Sets the document fields which should be searched. When no field is set, all fields will be searched. Custom options per field are also supported.false
enrichBooleanEnrich IDs from the results with the corresponding documents.false
bool"and"
"or"
Sets the used logical operator when searching through multiple fields or tags."or"