fuse.js vs lunr vs flexsearch vs js-search vs search-index vs elasticlunr
Local fuzzy search, full-text indexing and persistent search
fuse.jslunrflexsearchjs-searchsearch-indexelasticlunrSimilar Packages:

Local fuzzy search, full-text indexing and persistent search

Choose collection matching or an index model, then configure language processing, updates, result storage and persistence.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
fuse.js20,262,76720,534417 kB264 months agoApache-2.0
lunr9,480,4009,202-1306 years agoMIT
flexsearch1,288,66613,8242.33 MB40a year agoApache-2.0
js-search166,5802,212117 kB84 years agoMIT
search-index54,1371,421722 kB113 months agoMIT
elasticlunr26,6162,064-7710 years agoMIT

Additional indexing control

FlexSearch exposes Index and Document models with encoding/tokenization and multi-field configuration. Decide whether results are identifiers or enriched/stored records. Worker execution and persistence adapters are integration choices, not automatic properties of every in-memory index. Coordinate asynchronous updates and storage lifecycle through the selected interfaces.

Local collection or full-text index

Fuse.js searches a local record collection with configured keys and approximate matching. Its results can include items, scores and match information. Lower scores indicate closer matches, not probabilities, and cannot be compared numerically with another engine's ranking.

Lunr builds a document index and returns references, scores and match metadata. A prebuilt-index workflow is useful for relatively static content; the original documents and result UI remain application concerns. Elasticlunr uses its own field/reference configuration, addDoc and query-time boosting, with document-storage options. Similar terminology does not make query syntax or update behavior identical.

Js-search configures a document identifier and indexed fields through its Search API, then adds documents and searches them. Tokenization and optional stemming determine language behavior. It does not automatically inherit another engine's typo correction merely because both perform text search.

Persistence and execution

Search-index supplies asynchronous PUT/QUERY operations and persistent storage. Its current Node entry uses ClassicLevel, while the browser entry uses BrowserLevel. The package declares Node >=22; the actual dependency and selected environment also matter. Persistent index updates and an ordinary in-memory field search are different deployment contracts.

Evaluate relevance with real queries

Choose using the application's languages, typos, multiword terms, field priorities and update workload. Plan how documents reach the index, how result identifiers map back to records and how the UI displays matches. Timing is separate from relevance; no single ranking score or benchmark establishes an unconditional winner. These libraries do not automatically build a search UI or synchronize the source data.

How to Choose: fuse.js vs lunr vs flexsearch vs js-search vs search-index vs elasticlunr

  • fuse.js:

    Choose approximate matching over an in-memory collection and selected keys.

  • lunr:

    Choose a builder/prebuilt-index workflow with query syntax and reference-based results.

  • flexsearch:

    Choose configurable Index/Document search with the worker or persistence route explicitly selected.

  • js-search:

    Choose a local document search API with configured indexes and tokenization.

  • search-index:

    Choose a persistent asynchronous full-text index with environment-specific storage.

  • elasticlunr:

    Choose a local field-based index with document updates and query-time boosts.

README for fuse.js

Fuse.js

Node.js CI Version Downloads code style: prettier Contributors License

Fuse.js is a lightweight, zero-dependency fuzzy-search library written in TypeScript. It works in the browser and on the server, and is designed for searching small-to-medium datasets on the client side where you can't rely on a dedicated search backend.

✨ What's New: Token Search

Multi-word fuzzy search with relevance ranking. Type "javascrpt paterns" and find "JavaScript Patterns" — typo tolerance, multiple words, and smart ranking all at once.

const fuse = new Fuse(docs, {
  useTokenSearch: true,
  keys: ['title', 'author', 'description']
})

fuse.search('javascrpt paterns')
// → [{ item: { title: 'JavaScript Patterns', ... } }]

See Token Search below for details.

Web Workers

Search large datasets without freezing the UI. FuseWorker splits your data across multiple Web Workers and searches in parallel — ~5x faster on 100K documents.

import { FuseWorker } from 'fuse.js/worker'

const fuse = new FuseWorker(docs, {
  keys: ['title', 'author', 'description']
})

const results = await fuse.search('query')
fuse.terminate()

Same options and results as Fuse — just async. Function-valued options (sortFn, getFn, keys[].getFn) aren't supported because functions can't be transferred to a worker; everything else carries over. See the Web Workers docs for the interactive demo and full API.

Installation

npm install fuse.js
yarn add fuse.js

Or include directly via CDN:

<script src="https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.min.mjs"></script>

Quick Start

import Fuse from 'fuse.js'

const books = [
  { title: "Old Man's War", author: 'John Scalzi' },
  { title: 'The Lock Artist', author: 'Steve Hamilton' },
  { title: 'HTML5', author: 'Remy Sharp' },
  { title: 'JavaScript: The Good Parts', author: 'Douglas Crockford' }
]

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

fuse.search('javscript')
// → [{ item: { title: 'JavaScript: The Good Parts', ... }, ... }]

Features

Fuzzy Search

The core of Fuse.js. Uses the Bitap algorithm for approximate string matching — handles typos, misspellings, and partial matches out of the box.

fuse.search('javscript')
// → [{ item: { title: 'JavaScript: The Good Parts', author: 'Douglas Crockford' } }]

Weighted Keys

Search across multiple fields with different importance levels. Title matches can rank higher than description matches.

const fuse = new Fuse(docs, {
  keys: [
    { name: 'title', weight: 2 },
    { name: 'description', weight: 1 }
  ]
})

Extended Search

Use operators for precise control: exact match (=), prefix (^), suffix (!), and more. Enable with useExtendedSearch: true.

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

fuse.search('=exact match')   // exact match
fuse.search('^prefix')        // starts with
fuse.search('!term')          // does not include

Token Search

Splits multi-word queries into individual terms, fuzzy-matches each independently, and ranks results using BM25-style IDF weighting. Enable with useTokenSearch: true.

const fuse = new Fuse(docs, {
  useTokenSearch: true,
  keys: ['title', 'body']
})

fuse.search('express midleware rout')
// Finds "Express Middleware" and "Express Routing Guide" despite typos
  • Typo tolerance per word — each term is fuzzy-matched independently
  • Relevance ranking — rare terms are weighted higher than common ones
  • Word order independent — "patterns javascript" and "javascript patterns" return identical results
  • No query length limit — long multi-word queries work naturally since each term is searched separately
  • AND or OR — tokenMatch: 'all' returns only records matching every word (filtering); the default 'any' matches any word
  • Custom tokenizer — pass a regex or function via tokenize for tokens with internal punctuation (node.js, c++), or use Intl.Segmenter for CJK / Thai word segmentation. Unicode-aware by default

Available in the full build. See the Token Search docs for details and performance benchmarks.

Logical Search

Combine conditions with $and and $or for complex queries. Available in the full build.

fuse.search({
  $and: [
    { title: 'javascript' },
    { author: 'crockford' }
  ]
})

Match Highlighting

Get character-level match indices for highlighting search results in your UI.

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

const result = fuse.search('javscript')
// result[0].matches[0].indices → [[0, 9]]

Single String Matching

Use Fuse.match() to fuzzy-match a pattern against a single string without creating an index. Useful for one-off comparisons or custom filtering.

const result = Fuse.match('javscript', 'JavaScript: The Good Parts')
// → { isMatch: true, score: 0.04, indices: [[0, 9]] }

Fuse.match() does not support useTokenSearch — token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison can't provide. Passing useTokenSearch: true throws an explicit error. Use new Fuse(docs, { useTokenSearch: true }).search(query) for token-search behavior.

Dynamic Collections

Add and remove documents from a live index without rebuilding.

fuse.add({ title: 'New Book', author: 'New Author' })
fuse.remove((doc) => doc.title === 'Old Book')

Builds

Fuse.js ships in two variants:

BuildIncludesMin + gzip
FullFuzzy + Extended + Logical + Token search~8.6 kB
BasicFuzzy search only~6.8 kB

Use the basic build if you only need fuzzy search and want the smallest bundle size.

Documentation

For the full API reference, configuration options, scoring theory, and interactive demos, visit fusejs.io.

Official ports

  • fuse-swift: Swift port for iOS, macOS, tvOS, watchOS, visionOS, and Linux. Byte-equivalent results, idiomatic Swift API, syncs with each upstream release. Currently in 2.0.0-rc.1.

Supporting Fuse.js

Develop

See DEVELOPERS.md for setup, scripts, and project structure.

Contribute

See CONTRIBUTING.md for guidelines on issues and pull requests.