W↓
All docs
🔑
Sign Up/Sign In
www.fusejs.io/getting-started/ (+2)
Public Link
Apr 8, 2025, 12:40:25 PM - complete - 30.8 kB
Starting URLs:
https://www.fusejs.io/getting-started/installation.html
https://www.fusejs.io/api/options.html
Crawl Prefixes:
https://www.fusejs.io/getting-started/
https://www.fusejs.io/api/
https://www.fusejs.io/examples
## Page: https://www.fusejs.io/getting-started/installation.html Latest stable version: 7.1.0 ### npm npm install fuse.js ### Yarn yarn add fuse.js #### Importing ES6 module syntax: import Fuse from 'fuse.js' CommonJS: const Fuse = require('fuse.js') ### Direct `<script>` Include Simply download and include with a script tag. `Fuse` will be registered as a global variable. #### CDN For prototyping or learning purposes, you can use the latest version with: <script src="https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.js"></script> For production, we recommend linking to a specific version number and build to avoid unexpected breakage from newer versions: <script src="https://cdn.jsdelivr.net/npm/fuse.js@7.1.0"></script> If you are using native ES Modules, there is also an ES Modules compatible build: <script type="module"> import Fuse from 'https://cdn.jsdelivr.net/npm/fuse.js@7.1.0/dist/fuse.mjs' </script> You can browse the source of the npm package at cdn.jsdelivr.net/npm/fuse.jsopen in new window. Fuse.js is also available on unpkgopen in new window. Make sure to read about the different builds of Fuse.js and use the production version in your published site, replacing `fuse.js` with `fuse.min.js`. This is a smaller build optimized for speed instead of development experience. ### Deno You can directly import `Fuse` as an ES module from the deno.land/x service: // @deno-types="https://deno.land/x/fuse@v7.1.0/dist/fuse.d.ts" import Fuse from 'https://deno.land/x/fuse@v7.1.0/dist/fuse.min.mjs' **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/getting-started/different-builds.html In the `dist/` directory of the npm packageopen in new window you will find many different builds of Fuse.js. Here's an overview of the difference between them. | | UMD | CommonJS | ES Module (for bundlers) | | --- | --- | --- | --- | | **Full** | fuse.js | fuse.cjs | fuse.mjs | | **Basic** | fuse.basic.js | fuse.basic.cjs | fuse.basic.mjs | | **Full (Production)** | fuse.min.js | \- | fuse.min.mjs | | **Basic (Production)** | fuse.basic.min.js | \- | fuse.basic.min.mjs | ### Terms * **Full**: Builds that contain standard fuzzy searching, extended searching, and logical query operations. These builds are larger. * **Basic**: Builds that contain only standard fuzzy searching. * **UMDopen in new window**: UMD builds can be used directly in the browser via a `<script>` tag. The default file from jsDelivr CDN at https://cdn.jsdelivr.net/npm/fuse.js is the UMD build (`fuse.js`). * **CommonJSopen in new window**: CommonJS builds are intended for use with older bundlers like browserifyopen in new window or webpack 1open in new window. The file for these bundlers (`pkg.main`) is the CommonJS build (`fuse.cjs`). * **ES Moduleopen in new window**: Intended for use with modern bundlers like Webpack 2open in new window or Rollupopen in new window. The file for these bundlers (`pkg.module`) is the ES Module build (`fuse.mjs`). **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/options.html ## Basic Options ### `isCaseSensitive` * Type: `boolean` * Default: `false` Indicates whether comparisons should be case sensitive. ### `ignoreDiacritics` * Type: `boolean` * Default: `false` Indicates whether comparisons should ignore diacritics (accents). ### `includeScore` * Type: `boolean` * Default: `false` Whether the score should be included in the result set. A score of `0`indicates a perfect match, while a score of `1` indicates a complete mismatch. ### `includeMatches` * Type: `boolean` * Default: `false` Whether the matches should be included in the result set. When `true`, each record in the result set will include the indices of the matched characters. These can consequently be used for highlighting purposes. ### `minMatchCharLength` * Type: `number` * Default: `1` Only the matches whose length exceeds this value will be returned. (For instance, if you want to ignore single character matches in the result, set it to `2`). ### `shouldSort` * Type: `boolean` * Default: `true` Whether to sort the result list, by score. ### `findAllMatches` * Type: `boolean` * Default: `false` When true, the matching function will continue to the end of a search pattern even if a perfect match has already been located in the string. ### `keys` * Type: `Array` * Default: `[]` List of keys that will be searched. This supports nested paths, weighted search, searching in arrays of strings and objects. ## Fuzzy Matching Options ### `location` * Type: `number` * Default: `0` Determines approximately where in the text is the pattern expected to be found. ### `threshold` * Type: `number` * Default: `0.6` At what point does the match algorithm give up. A threshold of `0.0` requires a perfect match (of both letters and location), a threshold of `1.0` would match anything. ### `distance` * Type: `number` * Default: `100` Determines how close the match must be to the fuzzy location (specified by `location`). An exact letter match which is `distance` characters away from the fuzzy location would score as a complete mismatch. A `distance` of `0` requires the match be at the exact `location` specified. A distance of `1000` would require a perfect match to be within `800` characters of the `location` to be found using a `threshold` of `0.8`. ### `ignoreLocation` * Type: `boolean` * Default: `false` When `true`, search will ignore `location` and `distance`, so it won't matter where in the string the pattern appears. TIP The default options only search the first 60 characters. This should suffice if it is reasonably expected that the match is within this range. To modify this behavior, set the appropriate combination of `location`, `threshold`, `distance` (or `ignoreLocation`). To better understand how these options work together, read our Scoring Theory. ## Advanced Options ### `useExtendedSearch` * Type: `boolean` * Default: `false` When `true`, it enables the use of unix-like search commands. See example. ### `getFn` * Type: `Function` * Default: `(obj: T, path: string | string[]) => string | string[]` The function to use to retrieve an object's value at the provided path. The default will also search nested paths. ### `sortFn` * Type: `Function` * Default: `(a, b) => number` The function to use to sort all the results. The default will sort by ascending relevance score, ascending index. ### `ignoreFieldNorm` * Type: `boolean` * Default: `false` When `true`, the calculation for the relevance score (used for sorting) will ignore the field-length norm. TIP The only time it makes sense to set `ignoreFieldNorm` to `true` is when it does not matter how many terms there are, but only that the query term exists. ### `fieldNormWeight` * Type: `number` * Default: `1` Determines how much the field-length norm affects scoring. A value of `0` is equivalent to ignoring the field-length norm. A value of `0.5` will greatly reduce the effect of field-length norm, while a value of `2.0` will greatly increase it. **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/config.html You can access all options above via `Fuse.config`. This is useful if you want to override default options for all Fuse instances. **Example**: const options = { getFn: (obj, path) => { // Use the default `get` function const value = Fuse.config.getFn(obj, path) // ... do something with `value` return value } } **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/methods.html ### `search` Searches the entire collection of documents, and returns a list of search results. fuse.search(/* pattern , options*/) The pattern can be one of: * String * Path * Extended query * Logical query The options: * `limit` (type: `number`): Denotes the max number of returned search results. ### `setCollection` Set/replace the entire collection of documents. If no index is provided, one will be generated. Example: const fruits = ['apple', 'orange'] const fuse = new Fuse(fruits) fuse.setCollection(['banana', 'pear']) ### `add` Adds a doc to the collection. Example: const fruits = ['apple', 'orange'] const fuse = new Fuse(fruits) fuse.add('banana') console.log(fruits.length) // => 3 ### `remove` Removes all documents from the list which the predicate returns truthy for, and returns an array of the removed docs. The predicate is invoked with two arguments: `(doc, index)`. Example: const fruits = ['apple', 'orange', 'banana', 'pear'] const fuse = new Fuse(fruits) const results = fuse.remove((doc) => { return doc === 'banana' || doc === 'pear' }) console.log(fruits.length) // => 2 console.log(results) // => ['banana', 'pear'] ### `removeAt` Removes the doc at the specified index. Example: const fruits = ['apple', 'orange', 'banana', 'pear'] const fuse = new Fuse(fruits) fuse.removeAt(1) console.log(fruits) // => ['apple', 'banana', 'pear'] ### `getIndex` Returns the generated Fuse index. Example: const fruits = ['apple', 'orange', 'banana', 'pear'] const fuse = new Fuse(fruits) console.log(fuse.getIndex().size()) // => 4 **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/indexing.html ### `Fuse.createIndex` Pre-generate the index from the list, and pass it directly into the Fuse instance. If the list is (considerably) large, it speeds up instantiation. **Example** TIP Fuse will automatically index the table if one isn't provided during instantiation. ### `Fuse.parseIndex` Parses a serialized Fuse index from a json object representation. **Example** // (1) In the build step // Create the Fuse index const myIndex = Fuse.createIndex(['title', 'author.firstName'], books) // Serialize and save it fs.writeFile('fuse-index.json', JSON.stringify(myIndex.toJSON())) // (2) When app starts // Load and deserialize index const fuseIndex = await require('fuse-index.json') // Alternatively, if fetching the index, convert to json before parsing. const fuseIndex = await fetch('./fuse-index.json').then(r => r.json()) const myIndex = Fuse.parseIndex(fuseIndex) // initialize Fuse with the index const fuse = new Fuse(books, options, myIndex) **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/query.html Fuse.js supports logical query operators. These operators are used for filtering the data and getting precise results based on the given conditions. The following table contains the logical query operators: | Name | Description | | --- | --- | | $and | Returns all documents that match the conditions of **all** clauses. | | $or | Returns all documents that match the conditions of **any** clause. | ## `$and` { $and: [ { <expression_1> }, { <expression_2> } , ... , { <expression_N> } ] } The `$and` operator performs a logical **AND** operation on an array of expressions and selects the entries that satisfy all the expressions. The `$and` operator uses short-circuit evaluation (i.e, if the first expression evaluates to false, Fuse.js will not evaluate the remaining expressions). TIP Fuse.js provides an implicit **AND** operation when specifying a comma separated list of expressions. Using an explicit **AND** with the `$and` operator is necessary when the same field or operator has to be specified in multiple expressions. #### Example const result = fuse.search({ $and: [{ author: 'abc' }, { title: 'xyz' }] }) ## `$or` The `$or` operator performs a logical **OR** operation on an array expressions and selects the entries that satisfy at least one of the expressions. The `$or` operator uses short-circuit evaluation (i.e, if the first expression evaluates to true, Fuse.js will not evaluate the remaining expressions). #### Example const result = fuse.search({ $or: [{ author: 'abc' }, { author: 'def' }] }) ## Logical search with dotted keys To handle keys that contain dots, you can use the `$path` and `$val` properties when building the query. #### Example ## Use with Extended Searching Logical query operations pair quite nicely with extended searching. const result = fuse.search({ $and: [ { title: 'old war' }, // Fuzzy "old war" { color: "'blue" }, // Exact match for blue { $or: [ { title: '^lock' }, // Starts with "lock" { title: '!arts' } // Does not have "arts" ] } ] }) **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/examples.html * * * ## Search String Array ## Search Object Array ## Nested Search You can search through nested values with different ways: * define the path with dot notation (`.`) * define the path with array notation (`[]`) * Define a per-key `getFn` function IMPORTANT The path has to eventually point to a string, otherwise you will not get any results. ## Weighted Search You can allocate a weight to keys to give them higher (or lower) values in search results. The `weight` value has to be greater than `0`. ### Default `weight` When a `weight` isn't provided, it will default to `1`. In the following example, while `author` has been given a weight of `2`, `title` will be assigned a weight of `1`. const fuse = new Fuse(books, { keys: [ 'title', // will be assigned a `weight` of 1 { name: 'author', weight: 2 } ] }) Note that internally Fuse will normalize the weights to be within `0` and `1` exclusive. ## Extended Search This form of advanced searching allows you to fine-tune results. White space acts as an **AND** operator, while a single pipe (`|`) character acts as an **OR** operator. To escape white space, use double quote ex. `="scheme language"` for exact match. | Token | Match type | Description | | --- | --- | --- | | `jscript` | fuzzy-match | Items that fuzzy match `jscript` | | `=scheme` | exact-match | Items that are `scheme` | | `'python` | include-match | Items that include `python` | | `!ruby` | inverse-exact-match | Items that do not include `ruby` | | `^java` | prefix-exact-match | Items that start with `java` | | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` | | `.js$` | suffix-exact-match | Items that end with `.js` | | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` | White space acts as an **AND** operator, while a single pipe (`|`) character acts as an **OR** operator. **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/options.html ## Basic Options ### `isCaseSensitive` * Type: `boolean` * Default: `false` Indicates whether comparisons should be case sensitive. ### `ignoreDiacritics` * Type: `boolean` * Default: `false` Indicates whether comparisons should ignore diacritics (accents). ### `includeScore` * Type: `boolean` * Default: `false` Whether the score should be included in the result set. A score of `0`indicates a perfect match, while a score of `1` indicates a complete mismatch. ### `includeMatches` * Type: `boolean` * Default: `false` Whether the matches should be included in the result set. When `true`, each record in the result set will include the indices of the matched characters. These can consequently be used for highlighting purposes. ### `minMatchCharLength` * Type: `number` * Default: `1` Only the matches whose length exceeds this value will be returned. (For instance, if you want to ignore single character matches in the result, set it to `2`). ### `shouldSort` * Type: `boolean` * Default: `true` Whether to sort the result list, by score. ### `findAllMatches` * Type: `boolean` * Default: `false` When true, the matching function will continue to the end of a search pattern even if a perfect match has already been located in the string. ### `keys` * Type: `Array` * Default: `[]` List of keys that will be searched. This supports nested paths, weighted search, searching in arrays of strings and objects. ## Fuzzy Matching Options ### `location` * Type: `number` * Default: `0` Determines approximately where in the text is the pattern expected to be found. ### `threshold` * Type: `number` * Default: `0.6` At what point does the match algorithm give up. A threshold of `0.0` requires a perfect match (of both letters and location), a threshold of `1.0` would match anything. ### `distance` * Type: `number` * Default: `100` Determines how close the match must be to the fuzzy location (specified by `location`). An exact letter match which is `distance` characters away from the fuzzy location would score as a complete mismatch. A `distance` of `0` requires the match be at the exact `location` specified. A distance of `1000` would require a perfect match to be within `800` characters of the `location` to be found using a `threshold` of `0.8`. ### `ignoreLocation` * Type: `boolean` * Default: `false` When `true`, search will ignore `location` and `distance`, so it won't matter where in the string the pattern appears. TIP The default options only search the first 60 characters. This should suffice if it is reasonably expected that the match is within this range. To modify this behavior, set the appropriate combination of `location`, `threshold`, `distance` (or `ignoreLocation`). To better understand how these options work together, read our Scoring Theory. ## Advanced Options ### `useExtendedSearch` * Type: `boolean` * Default: `false` When `true`, it enables the use of unix-like search commands. See example. ### `getFn` * Type: `Function` * Default: `(obj: T, path: string | string[]) => string | string[]` The function to use to retrieve an object's value at the provided path. The default will also search nested paths. ### `sortFn` * Type: `Function` * Default: `(a, b) => number` The function to use to sort all the results. The default will sort by ascending relevance score, ascending index. ### `ignoreFieldNorm` * Type: `boolean` * Default: `false` When `true`, the calculation for the relevance score (used for sorting) will ignore the field-length norm. TIP The only time it makes sense to set `ignoreFieldNorm` to `true` is when it does not matter how many terms there are, but only that the query term exists. ### `fieldNormWeight` * Type: `number` * Default: `1` Determines how much the field-length norm affects scoring. A value of `0` is equivalent to ignoring the field-length norm. A value of `0.5` will greatly reduce the effect of field-length norm, while a value of `2.0` will greatly increase it. **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/getting-started/installation.html Latest stable version: 7.1.0 ### npm npm install fuse.js ### Yarn yarn add fuse.js #### Importing ES6 module syntax: import Fuse from 'fuse.js' CommonJS: const Fuse = require('fuse.js') ### Direct `<script>` Include Simply download and include with a script tag. `Fuse` will be registered as a global variable. #### CDN For prototyping or learning purposes, you can use the latest version with: <script src="https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.js"></script> For production, we recommend linking to a specific version number and build to avoid unexpected breakage from newer versions: <script src="https://cdn.jsdelivr.net/npm/fuse.js@7.1.0"></script> If you are using native ES Modules, there is also an ES Modules compatible build: <script type="module"> import Fuse from 'https://cdn.jsdelivr.net/npm/fuse.js@7.1.0/dist/fuse.mjs' </script> You can browse the source of the npm package at cdn.jsdelivr.net/npm/fuse.jsopen in new window. Fuse.js is also available on unpkgopen in new window. Make sure to read about the different builds of Fuse.js and use the production version in your published site, replacing `fuse.js` with `fuse.min.js`. This is a smaller build optimized for speed instead of development experience. ### Deno You can directly import `Fuse` as an ES module from the deno.land/x service: // @deno-types="https://deno.land/x/fuse@v7.1.0/dist/fuse.d.ts" import Fuse from 'https://deno.land/x/fuse@v7.1.0/dist/fuse.min.mjs' **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/getting-started/different-builds.html In the `dist/` directory of the npm packageopen in new window you will find many different builds of Fuse.js. Here's an overview of the difference between them. | | UMD | CommonJS | ES Module (for bundlers) | | --- | --- | --- | --- | | **Full** | fuse.js | fuse.cjs | fuse.mjs | | **Basic** | fuse.basic.js | fuse.basic.cjs | fuse.basic.mjs | | **Full (Production)** | fuse.min.js | \- | fuse.min.mjs | | **Basic (Production)** | fuse.basic.min.js | \- | fuse.basic.min.mjs | ### Terms * **Full**: Builds that contain standard fuzzy searching, extended searching, and logical query operations. These builds are larger. * **Basic**: Builds that contain only standard fuzzy searching. * **UMDopen in new window**: UMD builds can be used directly in the browser via a `<script>` tag. The default file from jsDelivr CDN at https://cdn.jsdelivr.net/npm/fuse.js is the UMD build (`fuse.js`). * **CommonJSopen in new window**: CommonJS builds are intended for use with older bundlers like browserifyopen in new window or webpack 1open in new window. The file for these bundlers (`pkg.main`) is the CommonJS build (`fuse.cjs`). * **ES Moduleopen in new window**: Intended for use with modern bundlers like Webpack 2open in new window or Rollupopen in new window. The file for these bundlers (`pkg.module`) is the ES Module build (`fuse.mjs`). **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/config.html You can access all options above via `Fuse.config`. This is useful if you want to override default options for all Fuse instances. **Example**: const options = { getFn: (obj, path) => { // Use the default `get` function const value = Fuse.config.getFn(obj, path) // ... do something with `value` return value } } **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/methods.html ### `search` Searches the entire collection of documents, and returns a list of search results. fuse.search(/* pattern , options*/) The pattern can be one of: * String * Path * Extended query * Logical query The options: * `limit` (type: `number`): Denotes the max number of returned search results. ### `setCollection` Set/replace the entire collection of documents. If no index is provided, one will be generated. Example: const fruits = ['apple', 'orange'] const fuse = new Fuse(fruits) fuse.setCollection(['banana', 'pear']) ### `add` Adds a doc to the collection. Example: const fruits = ['apple', 'orange'] const fuse = new Fuse(fruits) fuse.add('banana') console.log(fruits.length) // => 3 ### `remove` Removes all documents from the list which the predicate returns truthy for, and returns an array of the removed docs. The predicate is invoked with two arguments: `(doc, index)`. Example: const fruits = ['apple', 'orange', 'banana', 'pear'] const fuse = new Fuse(fruits) const results = fuse.remove((doc) => { return doc === 'banana' || doc === 'pear' }) console.log(fruits.length) // => 2 console.log(results) // => ['banana', 'pear'] ### `removeAt` Removes the doc at the specified index. Example: const fruits = ['apple', 'orange', 'banana', 'pear'] const fuse = new Fuse(fruits) fuse.removeAt(1) console.log(fruits) // => ['apple', 'banana', 'pear'] ### `getIndex` Returns the generated Fuse index. Example: const fruits = ['apple', 'orange', 'banana', 'pear'] const fuse = new Fuse(fruits) console.log(fuse.getIndex().size()) // => 4 **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/indexing.html ### `Fuse.createIndex` Pre-generate the index from the list, and pass it directly into the Fuse instance. If the list is (considerably) large, it speeds up instantiation. **Example** TIP Fuse will automatically index the table if one isn't provided during instantiation. ### `Fuse.parseIndex` Parses a serialized Fuse index from a json object representation. **Example** // (1) In the build step // Create the Fuse index const myIndex = Fuse.createIndex(['title', 'author.firstName'], books) // Serialize and save it fs.writeFile('fuse-index.json', JSON.stringify(myIndex.toJSON())) // (2) When app starts // Load and deserialize index const fuseIndex = await require('fuse-index.json') // Alternatively, if fetching the index, convert to json before parsing. const fuseIndex = await fetch('./fuse-index.json').then(r => r.json()) const myIndex = Fuse.parseIndex(fuseIndex) // initialize Fuse with the index const fuse = new Fuse(books, options, myIndex) **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/api/query.html Fuse.js supports logical query operators. These operators are used for filtering the data and getting precise results based on the given conditions. The following table contains the logical query operators: | Name | Description | | --- | --- | | $and | Returns all documents that match the conditions of **all** clauses. | | $or | Returns all documents that match the conditions of **any** clause. | ## `$and` { $and: [ { <expression_1> }, { <expression_2> } , ... , { <expression_N> } ] } The `$and` operator performs a logical **AND** operation on an array of expressions and selects the entries that satisfy all the expressions. The `$and` operator uses short-circuit evaluation (i.e, if the first expression evaluates to false, Fuse.js will not evaluate the remaining expressions). TIP Fuse.js provides an implicit **AND** operation when specifying a comma separated list of expressions. Using an explicit **AND** with the `$and` operator is necessary when the same field or operator has to be specified in multiple expressions. #### Example const result = fuse.search({ $and: [{ author: 'abc' }, { title: 'xyz' }] }) ## `$or` The `$or` operator performs a logical **OR** operation on an array expressions and selects the entries that satisfy at least one of the expressions. The `$or` operator uses short-circuit evaluation (i.e, if the first expression evaluates to true, Fuse.js will not evaluate the remaining expressions). #### Example const result = fuse.search({ $or: [{ author: 'abc' }, { author: 'def' }] }) ## Logical search with dotted keys To handle keys that contain dots, you can use the `$path` and `$val` properties when building the query. #### Example ## Use with Extended Searching Logical query operations pair quite nicely with extended searching. const result = fuse.search({ $and: [ { title: 'old war' }, // Fuzzy "old war" { color: "'blue" }, // Exact match for blue { $or: [ { title: '^lock' }, // Starts with "lock" { title: '!arts' } // Does not have "arts" ] } ] }) **❤️️ Fuse.js? Support its development with a small donation.** Donate --- ## Page: https://www.fusejs.io/examples.html * * * ## Search String Array ## Search Object Array ## Nested Search You can search through nested values with different ways: * define the path with dot notation (`.`) * define the path with array notation (`[]`) * Define a per-key `getFn` function IMPORTANT The path has to eventually point to a string, otherwise you will not get any results. ## Weighted Search You can allocate a weight to keys to give them higher (or lower) values in search results. The `weight` value has to be greater than `0`. ### Default `weight` When a `weight` isn't provided, it will default to `1`. In the following example, while `author` has been given a weight of `2`, `title` will be assigned a weight of `1`. const fuse = new Fuse(books, { keys: [ 'title', // will be assigned a `weight` of 1 { name: 'author', weight: 2 } ] }) Note that internally Fuse will normalize the weights to be within `0` and `1` exclusive. ## Extended Search This form of advanced searching allows you to fine-tune results. White space acts as an **AND** operator, while a single pipe (`|`) character acts as an **OR** operator. To escape white space, use double quote ex. `="scheme language"` for exact match. | Token | Match type | Description | | --- | --- | --- | | `jscript` | fuzzy-match | Items that fuzzy match `jscript` | | `=scheme` | exact-match | Items that are `scheme` | | `'python` | include-match | Items that include `python` | | `!ruby` | inverse-exact-match | Items that do not include `ruby` | | `^java` | prefix-exact-match | Items that start with `java` | | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` | | `.js$` | suffix-exact-match | Items that end with `.js` | | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` | White space acts as an **AND** operator, while a single pipe (`|`) character acts as an **OR** operator. **❤️️ Fuse.js? Support its development with a small donation.** Donate