Extended Search

Extended search enables unix-like search operators for fine-grained control over matching. Enable it with useExtendedSearch: true.

const fuse = new Fuse(list, {
  useExtendedSearch: true,
  keys: ['title', 'author']
})

Operators

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

Combining Operators

  • White space acts as AND — all terms must match.
  • Pipe (|) acts as OR — any group must match.
// Items that include "Man" AND "Old", OR end with "Artist"
fuse.search("'Man 'Old | Artist$")

This is parsed as two OR groups:

  1. 'Man AND 'Old — include "Man" and include "Old"
  2. Artist$ — ends with "Artist"

Quoting

Use double quotes to match phrases containing spaces:

fuse.search('="scheme language"') // exact match for "scheme language"
fuse.search("'^hello world")      // include-match for "hello world"

Example

const books = [
  { title: "Old Man's War", author: 'John Scalzi' },
  { title: 'The Lock Artist', author: 'Steve Hamilton' },
  { title: 'Artist for Life', author: 'Michelangelo' }
]

const fuse = new Fuse(books, {
  useExtendedSearch: true,
  keys: ['title']
})

// Starts with "Old" AND fuzzy match "war"
fuse.search('^Old war')

// Does NOT include "Artist" AND starts with "Old"
fuse.search('!Artist ^Old')

// Ends with "Artist" OR includes "War"
fuse.search("Artist$ | 'War")

Combining with Logical Queries

Extended search operators work inside logical queries:

fuse.search({
  $and: [
    { title: '^Old' },     // title starts with "Old"
    { author: "'Scalzi" }  // author includes "Scalzi"
  ]
})

Availability

Extended search is included in the full build. To use it with the basic build:

import Fuse from 'fuse.js/basic'
import { ExtendedSearch } from 'fuse.js'

Fuse.use(ExtendedSearch)
Last Updated: