Link Search Menu Expand Document

Options

Basic

shouldSort

type: boolean default: true desc: Whether to sort the result list, by score

Fuzzy

location

type: number default: 0 desc: Determines approximately where in the text is the pattern expected to be found.

threshold

type: number default: 0.6 desc: 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.

=== UseCase

  • set threshold to 0
const options = {
  // isCaseSensitive: false,
  // includeScore: false,
  // shouldSort: true,
  // includeMatches: false,
  // findAllMatches: false,
  // minMatchCharLength: 1,
  // location: 0,
  threshold: 0,
  // distance: 100,
  // useExtendedSearch: false,
  keys: [
    "title",
    "author.firstName"
  ]
};

const fuse = new Fuse(list, options);

=== Quickstart

yarn add fuse.js
// 1. List of items to search in
const books = [
  {
    title: "Old Man's War",
    author: {
      firstName: 'John',
      lastName: 'Scalzi'
    }
  },
  {
    title: 'The Lock Artist',
    author: {
      firstName: 'Steve',
      lastName: 'Hamilton'
    }
  }
]


// 2. Set up the Fuse instance
const fuse = new Fuse(books, {
  keys: ['title', 'author.firstName']
})


Table of contents


Copyright © 2020 Thence LLC