From 1eac7e4beedcc274faa91cdde29242b437afec71 Mon Sep 17 00:00:00 2001 From: Nick Chomey Date: Wed, 4 Mar 2026 07:30:41 -0600 Subject: [PATCH] convert HTML tables to markdown in docs --- README.md | 924 +++++-------------------------------- doc/custom-builds.md | 163 ++----- doc/document-search.md | 201 ++------ doc/encoder.md | 298 ++---------- doc/persistent.md | 105 +---- doc/resolver.md | 233 ++-------- doc/result-highlighting.md | 142 ++---- doc/worker.md | 44 +- 8 files changed, 347 insertions(+), 1763 deletions(-) diff --git a/README.md b/README.md index e5fc6404..f7af4932 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Getting instant help by the DeepWiki AI assistant: -[Basic Start](#load-library)  •  +[Basic Start](#load-library)  •  [API Reference](#api-overview)  •  [Encoder](doc/encoder.md)  •  [Document Search](doc/document-search.md)  •  @@ -98,124 +98,21 @@ Benchmarks: The benchmark was measured in terms per seconds, higher values are better (except the test "Memory"). The memory value refers to the amount of memory which was additionally allocated during search.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LibraryMemoryQuery: SingleQuery: MultiQuery: LargeQuery: Not Found
flexsearch1650955718119127301398111051706499
jsii21881384794955916359593730307
wade980604734432144191521239372
js-search23722982383775426609994803
minisearch4777305891916575849304233
orama5355294451702314454225491
elasticlunr3073143264855810120695840
lunr2443115275147688858103386
ufuzzy1375427997788585449557
bm2533963390347771265712471
fuzzysearch300147148229455276
fuse247107422321337329
+| Library | Memory | Query: Single | Query: Multi | Query: Large | Query: Not Found | +|-------------|--------|---------------|--------------|--------------|------------------| +| flexsearch | 16 | 50955718 | 11912730 | 13981110 | 51706499 | +| jsii | 2188 | 13847 | 949559 | 1635959 | 3730307 | +| wade | 980 | 60473 | 443214 | 419152 | 1239372 | +| js-search | 237 | 22982 | 383775 | 426609 | 994803 | +| minisearch | 4777 | 30589 | 191657 | 5849 | 304233 | +| orama | 5355 | 29445 | 170231 | 4454 | 225491 | +| elasticlunr | 3073 | 14326 | 48558 | 101206 | 95840 | +| lunr | 2443 | 11527 | 51476 | 88858 | 103386 | +| ufuzzy | 13754 | 2799 | 7788 | 58544 | 9557 | +| bm25 | 33963 | 3903 | 4777 | 12657 | 12471 | +| fuzzysearch | 300147 | 148 | 229 | 455 | 276 | +| fuse | 247107 | 422 | 321 | 337 | 329 | + Run Comparison: Performance Benchmark "Gulliver's Travels" @@ -304,120 +201,28 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/`
Download Builds
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - **** - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BuildFileCDN
flexsearch.bundle.min.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.min.js
flexsearch.bundle.debug.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.debug.js
flexsearch.bundle.module.min.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.min.js
flexsearch.bundle.module.debug.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.debug.js
flexsearch.compact.min.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.min.js
flexsearch.compact.debug.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.debug.js
flexsearch.compact.module.min.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.module.min.js
flexsearch.compact.module.debug.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.module.debug.js
flexsearch.light.min.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.min.js
flexsearch.light.debug.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.debug.js
flexsearch.light.module.min.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.module.min.js
flexsearch.light.module.debug.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.module.debug.js
flexsearch.es5.min.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.es5.min.js
flexsearch.es5.debug.jsDownloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.es5.debug.js
Javascript Modules (ESM)Downloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/module/
Javascript Modules Minified (ESM)Downloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/module-min/
Javascript Modules Debug (ESM)Downloadhttps://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/module-debug/
flexsearch.custom.jsRead more about "Custom Build"
+| | | | +|------------------------------------|----------|--------------------------------------------------------------------------------------------------| +| Build | File | CDN | +| flexsearch.bundle.min.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.min.js | +| flexsearch.bundle.debug.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.debug.js | +| flexsearch.bundle.module.min.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.min.js | +| flexsearch.bundle.module.debug.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.debug.js | +| flexsearch.compact.min.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.min.js | +| flexsearch.compact.debug.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.debug.js | +| flexsearch.compact.module.min.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.module.min.js | +| flexsearch.compact.module.debug.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.module.debug.js | +| flexsearch.light.min.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.min.js | +| flexsearch.light.debug.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.debug.js | +| flexsearch.light.module.min.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.module.min.js | +| flexsearch.light.module.debug.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.module.debug.js | +| flexsearch.es5.min.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.es5.min.js | +| flexsearch.es5.debug.js | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.es5.debug.js | +| Javascript Modules (ESM) | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/module/ | +| Javascript Modules Minified (ESM) | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/module-min/ | +| Javascript Modules Debug (ESM) | Download | https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/module-debug/ | +| flexsearch.custom.js | Read more about "Custom Build" | +
@@ -427,154 +232,27 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/` > The Node.js package includes all features. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Featureflexsearch.bundle.jsflexsearch.compact.jsflexsearch.light.js
- Presets -
- Async Processing - -
- Workers (Web + Node.js) - --
- Context Search -
- Document Search - -
- Document Datastore - -
- Partial Matching -
- Auto-Balanced Cache by Popularity/Last Queries - -
- Tag Search - -
- Suggestions -
- Phonetic Search (Fuzzy Search) - -
Encoder
Export / Import Indexes-
Resolver--
Result Highlighting-
Persistent Index (IndexedDB)--
File Size (gzip)16.3 kb11.4 kb4.5 kb
+| | | | | +|------------------------------------------------|----------------------|-----------------------|---------------------| +| Feature | flexsearch.bundle.js | flexsearch.compact.js | flexsearch.light.js | +| Presets | ✓ | ✓ | ✓ | +| Async Processing | ✓ | ✓ | - | +| Workers (Web + Node.js) | ✓ | - | - | +| Context Search | ✓ | ✓ | ✓ | +| Document Search | ✓ | ✓ | - | +| Document Datastore | ✓ | ✓ | - | +| Partial Matching | ✓ | ✓ | ✓ | +| Auto-Balanced Cache by Popularity/Last Queries | ✓ | ✓ | - | +| Tag Search | ✓ | ✓ | - | +| Suggestions | ✓ | ✓ | ✓ | +| Phonetic Search (Fuzzy Search) | ✓ | ✓ | - | +| Encoder | ✓ | ✓ | ✓ | +| Export / Import Indexes | ✓ | ✓ | - | +| Resolver | ✓ | - | - | +| Result Highlighting | ✓ | ✓ | - | +| Persistent Index (IndexedDB) | ✓ | - | - | +| File Size (gzip) | 16.3 kb | 11.4 kb | 4.5 kb | + @@ -657,7 +335,7 @@ Or import FlexSearch members separately by: ```html @@ -864,7 +542,7 @@ The documentation will refer to several examples. A list of all examples: - [document-worker](example/browser-module/document-worker) - [document-worker-extern-config](example/browser-module/document-worker-extern-config) - [language-pack](example/browser-module/language-pack) - + ## API Overview @@ -1069,7 +747,7 @@ const index = new Index({ }); ``` -Related Topics: [Index Options](#index-options) +Related Topics: [Index Options](#index-options)  •  [Resolution](#resolution)  •  [Charset Collection](#charset-collection)  •  [Tokenizer](#tokenizer-partial-match) @@ -1146,211 +824,37 @@ index.remove(0).update(1, 'foo').add(2, 'foobar'); ## 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" / "exact"
- "tolerant"
- "forward"
- "reverse" / "bidirectional
- "full" -
- Indicates how terms should be indexed by tokenization. - "strict"
resolution - Number - Sets the scoring resolution9
encoder - new Encoder(options)
- Charset.Exact
- Charset.Default
- Charset.Normalize
- Charset.LatinBalance
- Charset.LatinAdvanced
- Charset.LatinExtra
- Charset.LatinSoundex
- Charset.CJK
- false -
Choose one of the built-in encoder
Read more about Encoder
"default"
encode - function(string) => string[] - Pass a custom encoding function
Read more about Encoder
"default"
context - Boolean
- Context Options -
Enable/Disable context index. When passing "true" as a value will use the defaults for the context.false
cache - Boolean
- Number -
Enable/Disable and/or set capacity of cached entries.

The cache automatically balance stored entries related to their popularity.
false
fastupdate - Boolean - Additionally add a fastupdate index which boost any replace/update/remove task to a high performance level by also increasing index size by ~30%.false
priority - Number - Sets the task execution priority (1 low priority - 9 high priority) when using the async methods4
score - function(string) => number - Use a custom score function
keystore - Number - Increase available size for In-Memory-Index by additionally using uniform balanced registers (Keystore). You can apply values from 1 to 64.false
- Persistent Options: -
db - StorageInterface - Pass an instance of a persistent adapter
commit - Boolean - When disabled any changes won't commit, instead it needs calling index.commit() manually to make modifications to the index (add, update, remove) persistent.true
+| | | | | +|--------|--------|-------------|---------| +| Option | Values | Description | Default | +| preset | "memory", "performance", "match", "score", "default" | The configuration profile as a shortcut or as a base for your custom settings. | "default" | +| tokenize | "strict" / "exact", "tolerant", "forward", "reverse" / "bidirectional, "full" | Indicates how terms should be indexed by tokenization. | "strict" | +| resolution | Number | Sets the scoring resolution | 9 | +| encoder | new Encoder(options), Charset.Exact, Charset.Default, Charset.Normalize, Charset.LatinBalance, Charset.LatinAdvanced, Charset.LatinExtra, Charset.LatinSoundex, Charset.CJK, false | Choose one of the built-in encoderRead more about Encoder | "default" | +| encode | function(string) => string[] | Pass a custom encoding functionRead more about Encoder | "default" | +| context | Boolean | Context Options | Enable/Disable context index. When passing "true" as a value will use the defaults for the context. | false | +| cache | Boolean, Number | Enable/Disable and/or set capacity of cached entries.The cache automatically balance stored entries related to their popularity. | false | +| fastupdate | Boolean | Additionally add a fastupdate index which boost any replace/update/remove task to a high performance level by also increasing index size by ~30%. | false | +| priority | Number | Sets the task execution priority (1 low priority - 9 high priority) when using the async methods | 4 | +| score | function(string) => number | Use a custom score function | | +| keystore | Number | Increase available size for In-Memory-Index by additionally using uniform balanced registers (Keystore). You can apply values from 1 to 64. | false | +| Persistent Options: | +| db | StorageInterface | Pass an instance of a persistent adapter | | +| commit | Boolean | When disabled any changes won't commit, instead it needs calling index.commit() manually to make modifications to the index (add, update, remove) persistent. | true | + ## Search Options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
limitnumberSets the limit of results100
offsetnumberApply offset (skip items)0
resolutionnumberLimit the resolution (score) of the results
suggestBooleanEnables Suggestions in resultsfalse
cacheBooleanUse a Query Cachefalse
resolveBooleanWhen set to false, an instance of a Resolver is returned to apply further operationstrue
+| | | | | +|------------|---------|--------------------------------------------------------------------------------------|---------| +| Option | Values | Description | Default | +| limit | number | Sets the limit of results | 100 | +| offset | number | Apply offset (skip items) | 0 | +| resolution | number | Limit the resolution (score) of the results | | +| suggest | Boolean | Enables Suggestions in results | false | +| cache | Boolean | Use a Query Cache | false | +| resolve | Boolean | When set to false, an instance of a Resolver is returned to apply further operations | true | + ## Suggestions @@ -1408,49 +912,15 @@ The tokenizer is one of the most important options and heavily influence: Try to choose the most upper of these tokenizer which covers your requirements: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionDescriptionExampleMemory Factor (n = length of term)
"strict"
"exact"
"default"
index the full termfoobar1
"forward"index term in forward direction (supports right-to-left by Index option rtl: true)foobar
foobar
n
"reverse"
"bidirectional"
index term in both directionsfoobar
foobar
foobar
foobar
2n - 1
"tolerant"index the full term by also being tolerant against typos like swapped letters and missing lettersfoobra
foboar
foobr
fooba
2(n - 2) + 2
"full"index every consecutive partialfoobar
foobar
n * (n - 1)
+| | | | | +|--------------------------|---------------------------------------------------------------------------------------------------|--------------------------|------------------------------------| +| Option | Description | Example | Memory Factor (n = length of term) | +| "strict""exact""default" | index the full term | foobar | 1 | +| "forward" | index term in forward direction (supports right-to-left by Index option rtl: true) | foobarfoobar | n | +| "reverse""bidirectional" | index term in both directions | foobarfoobarfoobarfoobar | 2n - 1 | +| "tolerant" | index the full term by also being tolerant against typos like swapped letters and missing letters | foobrafoboarfoobrfooba | 2(n - 2) + 2 | +| "full" | index every consecutive partial | foobarfoobar | n * (n - 1) | + ## Charset Collection @@ -1459,62 +929,17 @@ Encoding is one of the most important task and heavily influence: 1. required memory / storage 2. capabilities of phonetic matches (Fuzzy-Search) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionDescriptionCharset TypeCompression Ratio
ExactBypass encoding and take exact inputUniversal (multi-lang)0%
Normalize
Default
Case in-sensitive encoding
Charset normalization
Letter deduplication
Universal (multi-lang)~ 7%
LatinBalanceCase in-sensitive encoding
Charset normalization
Letter deduplication
Phonetic basic transformation
Latin~ 30%
LatinAdvancedCase in-sensitive encoding
Charset normalization
Letter deduplication
Phonetic advanced transformation
Latin~ 45%
LatinExtraCase in-sensitive encoding
Charset normalization
Letter deduplication
Soundex-like transformation
Latin~ 60%
LatinSoundexFull Soundex transformationLatin~ 70%
function(str) => [str]Pass a custom encoding function to the Encoder
+| | | | | +|------------------------|-----------------------------------------------------------------------------------------------------|------------------------|-------------------| +| Option | Description | Charset Type | Compression Ratio | +| Exact | Bypass encoding and take exact input | Universal (multi-lang) | 0% | +| NormalizeDefault | Case in-sensitive encodingCharset normalizationLetter deduplication | Universal (multi-lang) | ~ 7% | +| LatinBalance | Case in-sensitive encodingCharset normalizationLetter deduplicationPhonetic basic transformation | Latin | ~ 30% | +| LatinAdvanced | Case in-sensitive encodingCharset normalizationLetter deduplicationPhonetic advanced transformation | Latin | ~ 45% | +| LatinExtra | Case in-sensitive encodingCharset normalizationLetter deduplicationSoundex-like transformation | Latin | ~ 60% | +| LatinSoundex | Full Soundex transformation | Latin | ~ 70% | +| function(str) => [str] | Pass a custom encoding function to the Encoder | | | + ## Fuzzy-Search @@ -1531,80 +956,16 @@ Additionally, you can apply custom `Mapper`, `Replacer`, `Stemmer`, `Filter` or Original term which was indexed: "Struldbrugs" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Encoder:ExactNormalize (Default)LatinBalanceLatinAdvancedLatinExtraLatinSoundex
Index Size3.1 Mb1.9 Mb1.7 Mb1.6 Mb1.1 Mb0.7 Mb
Struldbrugs
strũlldbrųĝgs
strultbrooks
shtruhldbrohkz
zdroltbrykz
struhlbrogger
+| Encoder: | Exact | Normalize (Default) | LatinBalance | LatinAdvanced | LatinExtra | LatinSoundex | +|----------------|--------|---------------------|--------------|---------------|------------|--------------| +| **Index Size** | **3.1 Mb** | **1.9 Mb** | **1.7 Mb** | **1.6 Mb** | **1.1 Mb** | **0.7 Mb** | +| Struldbrugs | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | +| strũlldbrųĝgs | | ✓ | ✓ | ✓ | ✓ | ✓ | +| strultbrooks | | | ✓ | ✓ | ✓ | ✓ | +| shtruhldbrohkz | | | | ✓ | ✓ | ✓ | +| zdroltbrykz | | | | | ✓ | ✓ | +| struhlbrogger | | | | | | ✓ | + The index size was measured after indexing the book "Gulliver's Travels". @@ -1658,7 +1019,7 @@ Create an index and apply custom options for the context: ```js var index = new FlexSearch({ tokenize: "strict", - context: { + context: { resolution: 5, depth: 3, bidirectional: true @@ -1696,42 +1057,13 @@ The first index returns ID 1 in the first slot for the best pick, because matche ### Context Options - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
resolution - Number - Sets the scoring resolution for the context.3
depth

- false
- Number -
Enable/Disable context index and also sets the maximum initial distance of related terms.1
bidirectional - Boolean - If enabled the context direction (aka "context chain") can move bidirectional. You should ony disable this options when you need a more exact match with fewer results.true
+| | | | | +|------------|--------|----------------------------------------------|---------| +| Option | Values | Description | Default | +| resolution | Number | Sets the scoring resolution for the context. | 3 | +| depth | false | Number | Enable/Disable context index and also sets the maximum initial distance of related terms. | 1 | +| bidirectional | Boolean | If enabled the context direction (aka "context chain") can move bidirectional. You should ony disable this options when you need a more exact match with fewer results. | true | + ## Auto-Balanced Cache (By Popularity) diff --git a/doc/custom-builds.md b/doc/custom-builds.md index aef7f507..bc7ad542 100644 --- a/doc/custom-builds.md +++ b/doc/custom-builds.md @@ -33,13 +33,13 @@ npm run build:custom SUPPORT_DOCUMENT=true SUPPORT_TAGS=true LANGUAGE_OUT=ECMASC Perform a custom build in ESM module format: ```bash -npm run build:custom RELEASE=custom.module SUPPORT_DOCUMENT=true SUPPORT_TAGS=true +npm run build:custom RELEASE=custom.module SUPPORT_DOCUMENT=true SUPPORT_TAGS=true ``` Perform a debug build: ```bash -npm run build:custom DEBUG=true SUPPORT_DOCUMENT=true SUPPORT_TAGS=true +npm run build:custom DEBUG=true SUPPORT_DOCUMENT=true SUPPORT_TAGS=true ``` > On custom builds each build flag will be set to `false` by default when not passed. @@ -54,136 +54,29 @@ The custom build will be saved to `dist/flexsearch.custom.xxxx.min.js` or when f ### Supported Build Flags - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FlagValuesInfo

Feature Flags
SUPPORT_WORKERtrue, falseWorker Indexes
SUPPORT_ENCODERtrue, falseWhen not included you'll need to pass a custom encode method when creating an index
SUPPORT_CHARSETtrue, falseIncludes: LatinBalance, LatinAdvanced, LatinExtra, LatinSoundex
SUPPORT_CACHEtrue, falseSupport for index.searchCache()
SUPPORT_ASYNCtrue, falseThe async version of index standard methods
SUPPORT_STOREtrue, falseDocument Datastore
SUPPORT_SUGGESTIONtrue, falseUse the option suggestions when searching
SUPPORT_SERIALIZEtrue, falseExport / Import / Serialize Index
SUPPORT_DOCUMENTtrue, falseDocument Indexes
SUPPORT_TAGStrue, falseTag-Search
SUPPORT_PERSISTENTtrue, falseUse any of the persistent indexes
SUPPORT_KEYSTOREtrue, falseExtended size for InMemory indexes
SUPPORT_RESOLVERtrue, falseApply complex queries by chaining boolean operations
SUPPORT_HIGHLIGHTINGtrue, falseResult Highlighting for Document-Search (also requires SUPPORT_STORE)

Compiler Flags
DEBUGtrue, falseApply common checks and throw errors more frequently, output debug information and helpful hints to the console
RELEASEcustom
custom.module
Choose build schema: custom = Legacy Browser (window.FlexSearch), custom.module = ES6 Modules (ESM)
POLYFILLtrue, falseInclude Polyfills (based on LANGUAGE_OUT)
PROFILERtrue, falseJust used for automatic performance tests
LANGUAGE_OUTECMASCRIPT3
ECMASCRIPT5
ECMASCRIPT_2015
ECMASCRIPT_2016
ECMASCRIPT_2017
ECMASCRIPT_2018
ECMASCRIPT_2019
ECMASCRIPT_2020
ECMASCRIPT_2021
ECMASCRIPT_2022
ECMASCRIPT_NEXT
STABLE
Target language
+| | | | +|------|--------|------| +| Flag | Values | Info | +| Feature Flags | +| SUPPORT_WORKER | true, false | Worker Indexes | +| SUPPORT_ENCODER | true, false | When not included you'll need to pass a custom encode method when creating an index | +| SUPPORT_CHARSET | true, false | Includes: LatinBalance, LatinAdvanced, LatinExtra, LatinSoundex | +| SUPPORT_CACHE | true, false | Support for index.searchCache() | +| SUPPORT_ASYNC | true, false | The async version of index standard methods | +| SUPPORT_STORE | true, false | Document Datastore | +| SUPPORT_SUGGESTION | true, false | Use the option suggestions when searching | +| SUPPORT_SERIALIZE | true, false | Export / Import / Serialize Index | +| SUPPORT_DOCUMENT | true, false | Document Indexes | +| SUPPORT_TAGS | true, false | Tag-Search | +| SUPPORT_PERSISTENT | true, false | Use any of the persistent indexes | +| SUPPORT_KEYSTORE | true, false | Extended size for InMemory indexes | +| SUPPORT_COMPRESSION | true, false | | +| SUPPORT_RESOLVER | true, false | Apply complex queries by chaining boolean operations | +| SUPPORT_HIGHLIGHTING | true, false | Result Highlighting for Document-Search (also requires SUPPORT_STORE) | +| Compiler Flags | +| DEBUG | true, false | Apply common checks and throw errors more frequently, output debug information and helpful hints to the console | +| RELEASE | customcustom.module | Choose build schema: custom = Legacy Browser (window.FlexSearch), custom.module = ES6 Modules (ESM) | +| POLYFILL | true, false | Include Polyfills (based on LANGUAGE_OUT) | +| PROFILER | true, false | Just used for automatic performance tests | +| LANGUAGE_OUT | ECMASCRIPT3ECMASCRIPT5ECMASCRIPT_2015ECMASCRIPT_2016ECMASCRIPT_2017ECMASCRIPT_2018ECMASCRIPT_2019ECMASCRIPT_2020ECMASCRIPT_2021ECMASCRIPT_2022ECMASCRIPT_NEXTSTABLE | Target language | + diff --git a/doc/document-search.md b/doc/document-search.md index 025aeb0d..2dcdf0d4 100644 --- a/doc/document-search.md +++ b/doc/document-search.md @@ -18,167 +18,58 @@ FlexSearch Documents also contain these features: > Document options basically inherits from [Index Options](../README.md#index-options), so you can apply most of those options either in the top scope of the config (for all fields) or as per field or both of them. - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
documentDocument DescriptorIncludes any specific information about how the document data should be indexed(mandatory)
workerBoolean
String
Enable a worker distributed model. Read more about here: Worker Indexfalse
+| Option | Values | Description | Default | +|----------|---------------------|---------------------------------------------------------------------------------|-------------| +| document | Document Descriptor | Includes any specific information about how the document data should be indexed | (mandatory) | +| worker | BooleanString | Enable a worker distributed model. Read more about here: Worker Index | false | + ### Document Search Options > Document search options basically inherit from [Index Search Options](../README.md#search-options), so you can apply most of those options either in the top scope of the config (for all fields) or as per field or both of them. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
index
field
String
Array<String>
Array<SearchOptions>
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.
tagObject<field:tag>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.
enrichBooleanEnrich IDs from the results with the corresponding documents.false
highlight - Highlighting Options
- String -
Highlight query matches in the result (for Document Indexes only)false
mergeBooleanMerge multiple fields in resultset into one and group results per IDfalse
pluckStringPick and apply search to just one field and return a flat result representationfalse
+| | | | | +|------------|-----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|---------| +| Option | Values | Description | Default | +| indexfield | StringArray<String>Array<SearchOptions> | 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. | | +| tag | Object<field:tag> | 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. | | +| enrich | Boolean | Enrich IDs from the results with the corresponding documents. | false | +| highlight | Highlighting Options + String | Highlight query matches in the result (for Document Indexes only) | false | +| merge | Boolean | Merge multiple fields in resultset into one and group results per ID | false | +| pluck | String | Pick and apply search to just one field and return a flat result representation | false | + ## The Document Descriptor When creating a `Document`-Index you will need to define a document descriptor in the field `document`. This descriptor is including any specific information about how the document data should be indexed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
idString"id"
indexString
Array<String>
Array<FieldOptions>
tagString
Array<String>
Array<FieldOptions>
storeBoolean
String
Array<String>
Array<FieldOptions>
false
+| | | | | +|--------|-----------------------------------------------------|-------------|---------| +| Option | Values | Description | Default | +| id | String | | "id" | +| index | StringArray<String>Array<FieldOptions> | | | +| tag | StringArray<String>Array<FieldOptions> | | | +| store | BooleanStringArray<String>Array<FieldOptions> | | false | + ### Field Options > You can use all standard [Index Options](../README.md#index-options) within field options. - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
fieldStringThe field name (colon seperated syntax)(mandatory)
filterFunction
customFunction
+| | | | | +|--------|----------|-----------------------------------------|-------------| +| Option | Values | Description | Default | +| field | String | The field name (colon seperated syntax) | (mandatory) | +| filter | Function | | | +| custom | Function | | | + Assuming our document has a simple data structure like this: ```json -{ - "id": 0, +{ + "id": 0, "content": "some text" } ``` @@ -198,8 +89,8 @@ const index = new Document({ }); // add documents to the index -index.add({ - id: 0, +index.add({ + id: 0, content: "some text" }); ``` @@ -432,7 +323,7 @@ const index = new Document({ Remember when searching you have to use the same colon-separated-string as a key from your field definition. ```js -index.search(query, { +index.search(query, { index: "contents:body:title" }); ``` @@ -499,7 +390,7 @@ function add(sequential_data){ // add to index index.add(record); } - } + } } // now just use add() helper method as usual: @@ -674,7 +565,7 @@ By passing the search option `merge: true` all fields of the result set will be When using `pluck` instead of `field` you can explicitly select just one field and get back a flat representation: ```js -index.search(query, { +index.search(query, { pluck: "title", enrich: true }); @@ -693,7 +584,7 @@ Like the property `index` within a document descriptor just define a property `t ```js const index = new Document({ - document: { + document: { id: "id", tag: "species", index: "content" @@ -723,7 +614,7 @@ You can perform a tag-specific search by: ```js index.search(query, { - tag: { species: "fish" } + tag: { species: "fish" } }); ``` @@ -806,7 +697,7 @@ Get entries of multiple tags (intersection): ```js const result = index.search({ //enrich: true, // enrich documents - tag: { + tag: { "genres": ["Documentary", "Short"], "startYear": "1894" } @@ -817,7 +708,7 @@ Combine tags with queries (intersection): ```js const result = index.search({ query: "Carmen", // forward tokenizer - tag: { + tag: { "genres": ["Documentary", "Short"], "startYear": "1894" } @@ -853,7 +744,7 @@ This will add the whole original content to the store: ```js const index = new Document({ - document: { + document: { index: "content", store: true } @@ -907,9 +798,9 @@ A short example of configuring a document store: ```js const index = new Document({ - document: { + document: { index: "content", - store: ["author", "email"] + store: ["author", "email"] } }); @@ -1013,7 +904,7 @@ const index = new Document({ field: "fullname", custom: function(data){ // return custom string - return data.firstname + " " + + return data.firstname + " " + data.lastname; } },{ diff --git a/doc/encoder.md b/doc/encoder.md index cd585ff6..1cf2259e 100644 --- a/doc/encoder.md +++ b/doc/encoder.md @@ -101,7 +101,7 @@ const encoder = new Encoder({ Instead of using `include` or `exclude` you can pass a regular expression or a string to the field `split`: ```js -const encoder = new Encoder({ +const encoder = new Encoder({ split: /\s+/ }); ``` @@ -109,7 +109,7 @@ const encoder = new Encoder({ E.g. this split configuration will tokenize every symbol/char from a content: ```js -const encoder = new Encoder({ +const encoder = new Encoder({ split: "" }); ``` @@ -137,7 +137,7 @@ Further reading: [Encoder Processing Workflow](#encoder-processing-workflow) Assign an encoder to an index: ```js -const index = new Index({ +const index = new Index({ encoder: encoder }); ``` @@ -251,264 +251,64 @@ encoder.addFilter(function(str){ Shortcut for just assigning one encoder configuration to an index: ```js -const index = new Index({ +const index = new Index({ encoder: Charset.Normalize }); ``` ## Encoder Options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
You can just choose one of those 3 options:
include - Encoder Split Options - Define which of the string contents should be included (inclusion properties defaults to false){ letter: true, number: true }
exclude - Encoder Split Options - Define which of the string contents should be excluded (exclusion properties defaults to true)false
split - false
- RegExp
- String
- Encoder Split Options -
- The expression used to split the content into terms - → include { letter: true, number: true }
Other options:
dedupe - Boolean - Deduplicate consecutive letters, e.g. "missing" to "mising"true
numeric - Boolean - By default, the extended numeric support (Triplets) inherits from chosen Encoder Split Options. You probably might want to disable Triplets to get a more exact result (fewer entries) in some cases.true
minlength - Number - Set the minimum term length which should be added to the index. This limit does not apply to the forward tokenizer. You still get results when just typing "f" on a term "flexsearch" when e.g. minlength: 4 was used.1
maxlength - Number - Set the maximum term length which should be added to the index. Larger content will drop.1
rtl - Boolean - Force Right-To-Left encoding (you should just apply this when the string content was not already encoded as RTL)false
normalize - true enable normalization (default)
- false disable normalization
- function(str) => str custom function -
The normalization stage will apply basic charset normalization e.g. by replacing "é" to "e"true
prepare - function(str) => str custom function - The preparation stage is a custom function direct followed when normalization was donefalse
finalize - function([str]) => [str] custom function - The finalization stage is a custom function executed at the last task in the encoding pipeline (here it gets an array of tokens and need to return an array of tokens)false
filter - Set(["and", "to", "be"])
- function(str) => bool custom function

- encoder.addFilter("and") -
Stop-word filter is like a blacklist of words to be filtered out from indexing at all (e.g. "and", "to" or "be"). This is also very useful when using Context Searchfalse
stemmer - Map([["ing", ""], ["ies", "y"]])

- encoder.addStemmer("ing", "") -
Stemmer will normalize several linguistic mutations of the same word (e.g. "run" and "running", or "property" and "properties"). This is also very useful when using Context Searchfalse
mapper - Map([["é", "e"], ["ß", "ss"]])

- encoder.addMapper("é", "e") -
Mapper will replace a single char (e.g. "é" into "e")false
matcher - Map([["and", "&"], ["usd", "$"]])

- encoder.addMatcher("and", "&") -
Matcher will do same as Mapper but instead of single chars it will replace char sequencesfalse
replacer - [/[^a-z0-9]/g, "", /([^aeo])h(.)/g, "$1$2"])

- encoder.addReplacer(/[^a-z0-9]/g, "") -
Replacer takes custom regular expressions and couldn't get optimized in the same way as Mapper or Matcher. You should take this as the last option when no other replacement can do the same.false
cache - Boolean - In some very rare situations (large consecutive content with high cardinality) it might be useful to disable the internal event-loop-cachetrue
+| | | | | +|--------|--------|-------------|---------| +| Option | Values | Description | Default | +| You can just choose one of those 3 options: | +| include | Encoder Split Options | Define which of the string contents should be included (inclusion properties defaults to false) | { letter: true, number: true } | +| exclude | Encoder Split Options | Define which of the string contents should be excluded (exclusion properties defaults to true) | false | +| split | false + RegExp + String + Encoder Split Options | The expression used to split the content into terms | → include { letter: true, number: true } | +| Other options: | +| dedupe | Boolean | Deduplicate consecutive letters, e.g. "missing" to "mising" | true | +| numeric | Boolean | By default, the extended numeric support (Triplets) inherits from chosen Encoder Split Options. You probably might want to disable Triplets to get a more exact result (fewer entries) in some cases. | true | +| minlength | Number | Set the minimum term length which should be added to the index. This limit does not apply to the forward tokenizer. You still get results when just typing "f" on a term "flexsearch" when e.g. minlength: 4 was used. | 1 | +| maxlength | Number | Set the maximum term length which should be added to the index. Larger content will drop. | 1 | +| rtl | Boolean | Force Right-To-Left encoding (you should just apply this when the string content was not already encoded as RTL) | false | +| normalize | true enable normalization (default) + false disable normalization + function(str) => str custom function | The normalization stage will apply basic charset normalization e.g. by replacing "é" to "e" | true | +| prepare | function(str) => str custom function | The preparation stage is a custom function direct followed when normalization was done | false | +| finalize | function([str]) => [str] custom function | The finalization stage is a custom function executed at the last task in the encoding pipeline (here it gets an array of tokens and need to return an array of tokens) | false | +| filter | Set(["and", "to", "be"]) + function(str) => bool custom function + encoder.addFilter("and") | Stop-word filter is like a blacklist of words to be filtered out from indexing at all (e.g. "and", "to" or "be"). This is also very useful when using Context Search | false | +| stemmer | Map([["ing", ""], ["ies", "y"]]) + encoder.addStemmer("ing", "") | Stemmer will normalize several linguistic mutations of the same word (e.g. "run" and "running", or "property" and "properties"). This is also very useful when using Context Search | false | +| mapper | Map([["é", "e"], ["ß", "ss"]]) + encoder.addMapper("é", "e") | Mapper will replace a single char (e.g. "é" into "e") | false | +| matcher | Map([["and", "&"], ["usd", "$"]]) + encoder.addMatcher("and", "&") | Matcher will do same as Mapper but instead of single chars it will replace char sequences | false | +| replacer | [/[^a-z0-9]/g, "", /([^aeo])h(.)/g, "$1$2"]) + encoder.addReplacer(/[^a-z0-9]/g, "") | Replacer takes custom regular expressions and couldn't get optimized in the same way as Mapper or Matcher. You should take this as the last option when no other replacement can do the same. | false | +| cache | Boolean | In some very rare situations (large consecutive content with high cardinality) it might be useful to disable the internal event-loop-cache | true | + > [!TIP] > The methods `.addMapper()`, `.addMatcher()` and `.addReplacer()` might be confusing. For this reason they will automatically resolve to the right one when just using the same method for every rule. You can simplify this e.g. by just use `.addReplacer()` for each of this 3 rules. ### Encoder Split Options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
letter - Boolean - Toggle inclusion of letters on/offtrue
number - Boolean - Toggle inclusion of numerics on/offtrue
symbol - Boolean - Toggle inclusion of symbols on/offfalse
punctuation - Boolean - - Toggle inclusion of punctuation on/off - false
control - Boolean - Toggle inclusion of control chars on/offfalse
char - String
- Array[String] -
Toggle inclusion of specific chars on/offfalse
+| | | | | +|-------------|---------|------------------------------------------|---------| +| Option | Values | Description | Default | +| letter | Boolean | Toggle inclusion of letters on/off | true | +| number | Boolean | Toggle inclusion of numerics on/off | true | +| symbol | Boolean | Toggle inclusion of symbols on/off | false | +| punctuation | Boolean | Toggle inclusion of punctuation on/off | false | +| control | Boolean | Toggle inclusion of control chars on/off | false | +| char | String + Array[String] | Toggle inclusion of specific chars on/off | false | + ## Custom Encoder diff --git a/doc/persistent.md b/doc/persistent.md index 1cc254d8..1b76d9a0 100644 --- a/doc/persistent.md +++ b/doc/persistent.md @@ -136,100 +136,17 @@ await index.commit(); The benchmark was measured in "terms per second". - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StoreAddSearch 1Search NReplaceRemoveNot FoundScaling
terms per secterms per secterms per secterms per secterms per secterms per sec
IndexedDB123,29883,82362,37057,410171,053425,744No
Redis1,566,091201,534859,463117,013129,595875,526Yes
Sqlite269,81229,627129,735174,4451,406,553122,566No
Postgres354,89424,32976,189324,5463,702,64750,305Yes
MongoDB515,93819,68481,558243,353485,19267,751Yes
Clickhouse1,436,99211,50722,196931,0263,276,84716,644Yes
+| Store | Add | Search 1 | Search N | Replace | Remove | Not Found | Scaling | +|------------|---------------|---------------|---------------|---------------|---------------|---------------|---------| +| | terms per sec | terms per sec | terms per sec | terms per sec | terms per sec | terms per sec | | +| Memory | 28,345,405 | 65,180,102 | 12,098,298 | 19,099,981 | 36,164,827 | 143,369,175 | No | +| IndexedDB | 123,298 | 83,823 | 62,370 | 57,410 | 171,053 | 425,744 | No | +| Redis | 1,566,091 | 201,534 | 859,463 | 117,013 | 129,595 | 875,526 | Yes | +| Sqlite | 269,812 | 29,627 | 129,735 | 174,445 | 1,406,553 | 122,566 | No | +| Postgres | 354,894 | 24,329 | 76,189 | 324,546 | 3,702,647 | 50,305 | Yes | +| MongoDB | 515,938 | 19,684 | 81,558 | 243,353 | 485,192 | 67,751 | Yes | +| Clickhouse | 1,436,992 | 11,507 | 22,196 | 931,026 | 3,276,847 | 16,644 | Yes | + __Search 1:__ Single term query
__Search N:__ Multi term query (Context-Search) diff --git a/doc/resolver.md b/doc/resolver.md index bd80e3c1..4b42841f 100644 --- a/doc/resolver.md +++ b/doc/resolver.md @@ -3,7 +3,7 @@ Retrieve an unresolved result: ```js -const raw = index.search("a short query", { +const raw = index.search("a short query", { resolve: false }); ``` @@ -29,7 +29,7 @@ raw.and( ... ) The default resolver: ```js -const raw = index.search("a short query", { +const raw = index.search("a short query", { resolve: false }); const result = raw.resolve(); @@ -53,7 +53,7 @@ The basic concept explained: ```js // 1. get one or multiple unresolved results -const raw1 = index.search("a short query", { +const raw1 = index.search("a short query", { resolve: false }); const raw2 = index.search("another query", { @@ -149,188 +149,47 @@ const result = new Resolver({ ## Resolver Tasks - - - - - - - - - - - - - - - - - - - - - - - - -
MethodDescriptionReturn
- .and(options,...)
- .or(options,...)
- .not(options,...)
- .xor(options,...) -
Apply an operationReturns a Resolver when resolve was not set to false within the options, otherwise it returns the result (or promise in async context).
- .limit(number)
- .offset(number)
- .boost(number) -
Apply boost, limit and offset to the resultReturns a Resolver
- .resolve(options) - Resolve resultsReturns the final result or promise in async context (can't be executed twice)
+| | | | +|--------|-------------|--------| +| Method | Description | Return | +| .and(options,...) + .or(options,...) + .not(options,...) + .xor(options,...) | Apply an operation | Returns a Resolver when resolve was not set to false within the options, otherwise it returns the result (or promise in async context). | +| .limit(number) + .offset(number) + .boost(number) | Apply boost, limit and offset to the result | Returns a Resolver | +| .resolve(options) | Resolve results | Returns the final result or promise in async context (can't be executed twice) | + ## Resolver Options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
Resolver Task Options:
query - String - The search query
index - Index
- Document -
Assign the index where the query should be applied to
suggest - Boolean - Enables suggestions in resultsfalse
boost - Number - Boost or reduce the score of this query0
async - Boolean - Use a parallel processing workflowfalse
queue - Boolean - Use a queued processing workflowfalse
- and
- or
- not
- xor
-
- Array<ResolverOptions> - Apply nested queries
resolve - Boolean - - Resolve the result immediately or not. When set to true all final resolve options are also allowed and there can't exist any further resolver operations. - false
Document Resolver Options:
field
pluck
- String - Select the Document field on which the query should apply to.
Final Resolve Options:
enrich - Boolean - Enrich IDs from the results with the corresponding documents (for Document Indexes only)true
highlight - Highlighting Options
- String -
Highlight query matches in the result (for Document Indexes only)
limit - Number - Sets the limit of results100
offset - Boolean - Apply offset (skip items)0
+| | | | | +|--------|--------|-------------|---------| +| Option | Values | Description | Default | +| Resolver Task Options: | +| query | String | The search query | | +| index | Index + Document | Assign the index where the query should be applied to | | +| suggest | Boolean | Enables suggestions in results | false | +| boost | Number | Boost or reduce the score of this query | 0 | +| async | Boolean | Use a parallel processing workflow | false | +| queue | Boolean | Use a queued processing workflow | false | +| and + or + not + xor | Array<ResolverOptions> | Apply nested queries | | +| resolve | Boolean | Resolve the result immediately or not. When set to true all final resolve options are also allowed and there can't exist any further resolver operations. | false | +| Document Resolver Options: | +| fieldpluck | String | Select the Document field on which the query should apply to. | | +| Final Resolve Options: | +| enrich | Boolean | Enrich IDs from the results with the corresponding documents (for Document Indexes only) | true | +| highlight | Highlighting Options + String | Highlight query matches in the result (for Document Indexes only) | | +| limit | Number | Sets the limit of results | 100 | +| offset | Boolean | Apply offset (skip items) | 0 | + ### Using Cached Queries @@ -341,7 +200,7 @@ const result = new Resolver({ query: "a query", cache: true }) -.and({ +.and({ query: "another query", cache: true }) @@ -361,7 +220,7 @@ const resolver = new Resolver({ query: "a query", async: true }) -.and({ +.and({ query: "another query", async: true }) @@ -380,7 +239,7 @@ const resolver = new Resolver({ query: "a query", async: true }) -.and({ +.and({ query: "another query", async: true }); @@ -403,7 +262,7 @@ const resolver = await new Resolver({ query: "a query", async: true }) -.and({ +.and({ query: "another query", queue: true }) @@ -418,7 +277,7 @@ When tasks are processed consecutively, it will skip specific resolver stages wh ### Compare Parallel VS. Consecutive -When using the parallel workflow by passing `{ async: true }`, all resolver stages will send their requests (including nested tasks) to the DB immediately and calculate the results in the right order as soon as the request resolves. When the overall workload of your applications has some free resources, a parallel request workflow improves performance compared to the consecutive counterpart. +When using the parallel workflow by passing `{ async: true }`, all resolver stages will send their requests (including nested tasks) to the DB immediately and calculate the results in the right order as soon as the request resolves. When the overall workload of your applications has some free resources, a parallel request workflow improves performance compared to the consecutive counterpart.
@@ -439,7 +298,7 @@ function CustomResolver(raw){ return output; } -const result = index.search("a short query", { +const result = index.search("a short query", { resolve: CustomResolver }); ``` diff --git a/doc/result-highlighting.md b/doc/result-highlighting.md index c094b697..a89943bd 100644 --- a/doc/result-highlighting.md +++ b/doc/result-highlighting.md @@ -10,7 +10,7 @@ Alternatively you can simply upgrade id-content-pairs to a flat document when ca // 1. create the document index const index = new Document({ document: { - // using store is required + // using store is required store: true, index: [{ field: "title", @@ -33,7 +33,7 @@ index.add({ // 3. perform a query const result = index.search({ query: "karmen or clown or not found", - // also get results when query has no exact match + // also get results when query has no exact match suggest: true, // use highlighting options or pass a template, where $1 is // a placeholder for the matched partial @@ -60,116 +60,26 @@ There are several options to customize result highlighting. ### Highlighting Options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescriptionDefault
template - String - The template to be applied on matches (e.g. "<b>$1</b>"), where $1 is a placeholder for the matched partial(mandatory)
boundary - Boundary Options
- Number -
Limit the total length of highlighted content (add ellipsis by default). The template markup does not stack to the total length.false
ellipsis - Ellipsis Options
- Boolean
- String -
- Define a custom ellipsis or disable - "..."
merge +| | | | | +|----------|--------|-------------------------------------------------------------------------------------------------------------------|-------------| +| Option | Values | Description | Default | +| template | String | The template to be applied on matches (e.g. "<b>$1</b>"), where $1 is a placeholder for the matched partial | (mandatory) | +| boundary | Boundary Options + Number | Limit the total length of highlighted content (add ellipsis by default). The template markup does not stack to the total length. | false | +| ellipsis | Ellipsis Options Boolean - Wrap consecutive matches by just a single templatefalse
clip - Boolean - Allow to clip termstrue
Boundary Options
boundary.total - Number - Limit the total length of highlighted contentfalse
boundary.before - Number - Limit the length of content before highlighted parts(auto)
boundary.after - Number - Limit the length of content after highlighted parts(auto)
Ellipsis Options
ellipsis.template - String - The template to be applied on ellipsis (e.g. "<i>$1</i>"), where $1 is a placeholder for the ellipsis(mandatory)
ellipsis.pattern - Boolean
- String -
- Define a custom ellipsis or disable - "..."
+ String | Define a custom ellipsis or disable | "..." | +| merge | Boolean | Wrap consecutive matches by just a single template | false | +| clip | Boolean | Allow to clip terms | true | +| Boundary Options | +| boundary.total | Number | Limit the total length of highlighted content | false | +| boundary.before | Number | Limit the length of content before highlighted parts | (auto) | +| boundary.after | Number | Limit the length of content after highlighted parts | (auto) | +| Ellipsis Options | +| ellipsis.template | String | The template to be applied on ellipsis (e.g. "<i>$1</i>"), where $1 is a placeholder for the ellipsis | (mandatory) | +| ellipsis.pattern | Boolean + String | Define a custom ellipsis or disable | "..." | + ### Boundaries & Alignment @@ -209,7 +119,7 @@ const result = index.search({ }); ``` > The highlight markup does not stack to the total length. -> +> Result: ```js "...um dolor sit amet consetet..." @@ -282,12 +192,12 @@ const result = index.search({ highlight: { template: "$1", boundary: { - // length before match + // length before match before: 3, - // length after match + // length after match after: 15, - // overall length - total: 32 + // overall length + total: 32 } } }); diff --git a/doc/worker.md b/doc/worker.md index 006e3ca0..b37e518d 100644 --- a/doc/worker.md +++ b/doc/worker.md @@ -17,21 +17,21 @@ Documents will create worker automatically for each field by just apply the opti ```js const index = new Document({ worker: true, - document: { + document: { id: "id", index: ["name", "title"], tag: ["cat"] } }); -index.add({ - id: 1, cat: "catA", name: "Tom", title: "some" +index.add({ + id: 1, cat: "catA", name: "Tom", title: "some" }).add({ id: 2, cat: "catA", name: "Ben", title: "title" -}).add({ +}).add({ id: 3, cat: "catB", name: "Max", title: "to" -}).add({ - id: 4, cat: "catB", name: "Tim", title: "index"" +}).add({ + id: 4, cat: "catB", name: "Tim", title: "index"" }); ``` @@ -105,31 +105,13 @@ const index = new Worker({ options }); > Worker-Index Options extends the default [Index Options](../README.md#index-options), you can apply also. - - - - - - - - - - - - - - - - - - - - - - - - -
OptionValuesDescription
configStringEither the absolute URL to the config file when used in Browser context (should match the Same-Origin-Policy) or the filepath to the configuration file when used in Node.js context
exportfunctionThe export handler function. Read more about Export
importfunctionThe export handler function. Read more about Import
+| | | | +|--------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Option | Values | Description | +| config | String | Either the absolute URL to the config file when used in Browser context (should match the Same-Origin-Policy) or the filepath to the configuration file when used in Node.js context | +| export | function | The export handler function. Read more about Export | +| import | function | The export handler function. Read more about Import | + ## Extern Worker Configuration