Examples


Search String Array

Search Object Array

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.

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.

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.

TokenMatch typeDescription
jscriptfuzzy-matchItems that fuzzy match jscript
=schemeexact-matchItems that are scheme
'pythoninclude-matchItems that include python
!rubyinverse-exact-matchItems that do not include ruby
^javaprefix-exact-matchItems that start with java
!^earlanginverse-prefix-exact-matchItems that do not start with earlang
.js$suffix-exact-matchItems that end with .js
!.go$inverse-suffix-exact-matchItems that do not end with .go

White space acts as an AND operator, while a single pipe (|) character acts as an OR operator.

Last Updated: