- Async Processing + Async Processing | ✓ | ✓ | @@ -428,7 +429,7 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/`||||||||||||||||||||||||||||||||||||||||||
- Workers (Web + Node.js) + Workers (Web + Node.js) | ✓ | - | @@ -437,7 +438,7 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/`||||||||||||||||||||||||||||||||||||||||||
- Context Search + Context Search | ✓ | ✓ | @@ -446,7 +447,7 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/`||||||||||||||||||||||||||||||||||||||||||
- Document Search + Document Search | ✓ | ✓ | @@ -455,7 +456,7 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/`||||||||||||||||||||||||||||||||||||||||||
- Document Store + Document Store | ✓ | ✓ | @@ -473,16 +474,7 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/`||||||||||||||||||||||||||||||||||||||||||
- Relevance Scoring - | -✓ | -✓ | -✓ | -|||||||||||||||||||||||||||||||||||||||||
- Auto-Balanced Cache by Popularity/Last Queries + Auto-Balanced Cache by Popularity/Last Queries | ✓ | ✓ | @@ -491,7 +483,7 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/`||||||||||||||||||||||||||||||||||||||||||
- Tag Search + Tag Search | ✓ | ✓ | @@ -509,7 +501,7 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/`||||||||||||||||||||||||||||||||||||||||||
- Phonetic Search (Fuzzy Search) + Phonetic Search (Fuzzy Search) | ✓ | ✓ | @@ -517,28 +509,28 @@ The **_dist_** folder is located in: `node_modules/flexsearch/dist/`||||||||||||||||||||||||||||||||||||||||||
Encoder | +Encoder | ✓ | ✓ | ✓ | ||||||||||||||||||||||||||||||||||||||||
Export / Import Indexes | +Export / Import Indexes | ✓ | ✓ | - | ||||||||||||||||||||||||||||||||||||||||
Resolver | +Resolver | ✓ | - | - | ||||||||||||||||||||||||||||||||||||||||
Persistent Index (IndexedDB) | +Persistent Index (IndexedDB) | ✓ | - | - | @@ -700,15 +692,15 @@ const index = new FlexSearch.Index(/* ... */); Or require FlexSearch members separately by: ```js -const { Index, Document, Encoder, Charset, Resolver, Worker, IndexedDB } = require("flexsearch"); +const { Index, Document, Encoder, Charset, Resolver, Worker } = require("flexsearch"); const index = new Index(/* ... */); ``` When using ESM instead of CommonJS: ```js -import { Index, Document, Encoder, Charset, Resolver, Worker, IndexedDB } from "flexsearch"; -const index = new FlexSearch.Index(/* ... */); +import { Index, Document, Encoder, Charset, Resolver, Worker } from "flexsearch"; +const index = new Index(/* ... */); ``` Language packs are accessible via: @@ -746,19 +738,17 @@ index.add(id, text); const result = index.search(text, options); ``` -```js -worker.add(id, text); -const result = worker.search(text, options); -``` - ```js document.add(doc); const result = document.search(text, options); ``` -Each of these index types have a persistent model (optionally). So, persistent index isn't a new 4th index type, instead it extends the existing ones. +```js +await worker.add(id, text); +const result = await worker.search(text, options); +``` -> Every method called on a `Worker` index is treated as async. You will get back a `Promise` or you can provide a callback function as the last parameter additionally. +> Every method called on a `Worker` index is treated as async. You will get back a `Promise` or you can provide a callback function as the last parameter alternatively. ### Common Code Examples @@ -766,7 +756,7 @@ The documentation will refer to several examples. A list of all examples:||||||||||||||||||||||||||||||||||||||||
Option | Description | +Charset Type | Compression Ratio | |||||||||||||||||||||||||||||||||||||||||
Exact |
Bypass encoding and take exact input | +Universal (multi-lang) | 0% | |||||||||||||||||||||||||||||||||||||||||
Default |
- Case in-sensitive encoding | -3% | -||||||||||||||||||||||||||||||||||||||||||
Normalize |
- Case in-sensitive encoding Charset normalization |
+ Normalize (Default) |
+ Case in-sensitive encoding Charset normalization Letter deduplication |
+ Universal (multi-lang) | ~ 7% | |||||||||||||||||||||||||||||||||||||||
LatinBalance |
- Case in-sensitive encoding Charset normalization Phonetic basic transformation |
+ Case in-sensitive encoding Charset normalization Letter deduplication Phonetic basic transformation |
+ Latin | ~ 30% | ||||||||||||||||||||||||||||||||||||||||
LatinAdvanced |
- Case in-sensitive encoding Charset normalization Phonetic advanced transformation |
+ Case in-sensitive encoding Charset normalization Letter deduplication Phonetic advanced transformation |
+ Latin | ~ 45% | ||||||||||||||||||||||||||||||||||||||||
LatinExtra |
- Case in-sensitive encoding Charset normalization Soundex-like transformation |
+ Case in-sensitive encoding Charset normalization Letter deduplication Soundex-like transformation |
+ Latin | ~ 60% | ||||||||||||||||||||||||||||||||||||||||
LatinSoundex |
Full Soundex transformation | +Latin | ~ 70% | |||||||||||||||||||||||||||||||||||||||||
function(str) => [str] |
Pass a custom encoding function to the Encoder |
+ Latin |
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 | ++ | + | + | + | + | ✓ | +
Encoder: | -LatinExact |
- LatinDefault |
- LatinSimple |
- LatinBalance |
- LatinAdvanced |
- LatinExtra |
- LatinSoundex |
-
---|---|---|---|---|---|---|---|
Index Size | -3.1 Mb | -1.9 Mb | -1.8 Mb | -1.7 Mb | -1.6 Mb | -1.1 Mb | -0.7 Mb | -
Struldbrugs | -✓ | -✓ | -✓ | -✓ | -✓ | -✓ | -✓ | -
struldbrugs | -- | ✓ | -✓ | -✓ | -✓ | -✓ | -✓ | -
strũldbrųĝgs | -- | - | ✓ | -✓ | -✓ | -✓ | -✓ | -
strultbrooks | -- | - | - | ✓ | -✓ | -✓ | -✓ | -
shtruhldbrohkz | -- | - | - | - | ✓ | -✓ | -✓ | -
zdroltbrykz | -- | - | - | - | - | ✓ | -✓ | -
struhlbrogger | -- | - | - | - | - | - | ✓ | -
Field | -Category | -Description | -
encode | -charset | -The encoder function. Has to return an array of separated words (or an empty string). | -
rtl | -charset | -A boolean property which indicates right-to-left encoding. | -
filter | -language | -Filter are also known as "stopwords", they completely filter out words from being indexed. | -
stemmer | -language | -Stemmer removes word endings and is a kind of "partial normalization". A word ending just matched when the word length is bigger than the matched partial. | -
matcher | -language | -Matcher replaces all occurrences of a given string regardless of its position and is also a kind of "partial normalization". | -
-
-
Encoder: | -LatinExact |
- LatinDefault |
- LatinSimple |
- LatinBalance |
- LatinAdvanced |
- LatinExtra |
- LatinSoundex |
-
---|---|---|---|---|---|---|---|
Index Size | -3.1 Mb | -1.9 Mb | -1.8 Mb | -1.7 Mb | -1.6 Mb | -1.1 Mb | -0.7 Mb | -
Struldbrugs | -✓ | -✓ | -✓ | -✓ | -✓ | -✓ | -✓ | -
struldbrugs | -- | ✓ | -✓ | -✓ | -✓ | -✓ | -✓ | -
strũldbrųĝgs | -- | - | ✓ | -✓ | -✓ | -✓ | -✓ | -
strultbrooks | -- | - | - | ✓ | -✓ | -✓ | -✓ | -
shtruhldbrohkz | -- | - | - | - | ✓ | -✓ | -✓ | -
zdroltbrykz | -- | - | - | - | - | ✓ | -✓ | -
struhlbrogger | -- | - | - | - | - | - | ✓ | -
Field | +Category | +Description | +
encode | +charset | +The encoder function. Has to return an array of separated words (or an empty string). | +
rtl | +charset | +A boolean property which indicates right-to-left encoding. | +
filter | +language | +Filter are also known as "stopwords", they completely filter out words from being indexed. | +
stemmer | +language | +Stemmer removes word endings and is a kind of "partial normalization". A word ending just matched when the word length is bigger than the matched partial. | +
matcher | +language | +Matcher replaces all occurrences of a given string regardless of its position and is also a kind of "partial normalization". | +