fuse.js vs algoliasearch vs lunr vs js-search vs search-index vs elasticlunr
搜尋庫
fuse.jsalgoliasearchlunrjs-searchsearch-indexelasticlunr類似套件:

搜尋庫

這些搜尋庫提供了不同的解決方案來實現高效的搜尋功能。它們各自具有獨特的特性和用途,適合不同的應用場景和需求。這些庫可以幫助開發者在應用程式中實現快速且準確的搜尋體驗,無論是小型專案還是大型系統。

npm下載趨勢

3 年

GitHub Stars 排名

統計詳情

套件
下載數
Stars
大小
Issues
發布時間
許可
fuse.js20,262,76720,534417 kB264 個月前Apache-2.0
algoliasearch9,562,5641,3842.4 MB242 天前MIT
lunr9,480,4009,202-1306 年前MIT
js-search166,5802,212117 kB84 年前MIT
search-index54,1371,421722 kB113 個月前MIT
elasticlunr26,6162,064-7710 年前MIT

功能比較: fuse.js vs algoliasearch vs lunr vs js-search vs search-index vs elasticlunr

即時搜尋

  • fuse.js:

    Fuse.js 提供即時搜尋功能,能夠快速回應用戶的輸入,適合需要快速反饋的場景。

  • algoliasearch:

    AlgoliaSearch 提供即時搜尋功能,能夠快速返回結果,適合需要即時反饋的應用。

  • lunr:

    Lunr 支持即時搜尋,能夠快速返回結果,適合靜態網站。

  • js-search:

    js-search 提供即時搜尋功能,能夠快速過濾結果,適合中小型專案。

  • search-index:

    search-index 支持即時搜尋,但需要在伺服器端進行索引,適合大型應用。

  • elasticlunr:

    ElasticLunr 不支持即時搜尋,但可以在客戶端快速進行搜尋,適合小型專案。

模糊搜尋

  • fuse.js:

    Fuse.js 提供高效的模糊搜尋功能,能夠處理拼寫錯誤,適合需要靈活搜尋的場景。

  • algoliasearch:

    AlgoliaSearch 提供強大的模糊搜尋功能,能夠處理拼寫錯誤和相似詞,提升搜尋體驗。

  • lunr:

    Lunr 支持模糊搜尋,但主要針對精確匹配,適合靜態網站。

  • js-search:

    js-search 支持基本的模糊搜尋,但不如其他庫強大,適合簡單需求。

  • search-index:

    search-index 提供模糊搜尋功能,能夠處理拼寫錯誤,適合大型應用。

  • elasticlunr:

    ElasticLunr 支持基本的模糊搜尋,但功能較為有限,適合簡單需求。

索引方式

  • fuse.js:

    Fuse.js 在客戶端進行索引,簡單易用,適合快速集成。

  • algoliasearch:

    AlgoliaSearch 使用雲端索引,能夠快速擴展和管理數據。

  • lunr:

    Lunr 在客戶端建立索引,適合靜態網站,能夠快速搜尋。

  • js-search:

    js-search 在客戶端建立索引,適合中小型專案,易於使用。

  • search-index:

    search-index 在伺服器端建立索引,適合大型應用,支持持久化數據。

  • elasticlunr:

    ElasticLunr 在客戶端建立索引,適合小型專案和靜態網站。

擴展性

  • fuse.js:

    Fuse.js 提供簡單的擴展性,能夠自定義搜尋邏輯,適合中小型專案。

  • algoliasearch:

    AlgoliaSearch 提供 API 擴展性,能夠與其他服務集成,適合大型應用。

  • lunr:

    Lunr 提供一定的擴展性,適合靜態網站。

  • js-search:

    js-search 提供基本的擴展性,適合簡單需求。

  • search-index:

    search-index 提供良好的擴展性,適合需要持久化數據的應用。

  • elasticlunr:

    ElasticLunr 的擴展性有限,適合小型專案。

學習曲線

  • fuse.js:

    Fuse.js 的學習曲線非常平緩,易於集成和使用。

  • algoliasearch:

    AlgoliaSearch 的學習曲線較平緩,適合快速上手。

  • lunr:

    Lunr 的學習曲線較簡單,適合靜態網站開發者。

  • js-search:

    js-search 的學習曲線較為平緩,適合快速上手。

  • search-index:

    search-index 的學習曲線較陡,適合有經驗的開發者。

  • elasticlunr:

    ElasticLunr 的學習曲線較簡單,適合新手使用。

如何選擇: fuse.js vs algoliasearch vs lunr vs js-search vs search-index vs elasticlunr

  • fuse.js:

    選擇 Fuse.js 如果你需要一個模糊搜尋的解決方案,並且想要在客戶端進行搜尋。它的設定簡單,適合需要快速集成的情況。

  • algoliasearch:

    選擇 AlgoliaSearch 如果你需要一個即時搜尋解決方案,並且願意使用雲端服務。它提供強大的搜尋功能和即時結果,但需要付費。

  • lunr:

    選擇 Lunr 如果你需要一個功能強大的全文搜尋解決方案,並且希望在客戶端進行索引。它適合靜態網站和需要快速搜尋的應用。

  • js-search:

    選擇 js-search 如果你需要一個簡單易用的搜尋庫,並且希望能夠自定義搜尋邏輯。它適合中小型專案,並且不需要複雜的配置。

  • search-index:

    選擇 search-index 如果你需要一個可擴展的搜尋解決方案,並且希望能夠在 Node.js 環境中運行。它適合大型應用和需要持久化搜尋數據的情況。

  • elasticlunr:

    選擇 ElasticLunr 如果你需要一個輕量級的前端搜尋解決方案,並且希望在客戶端進行搜尋而不依賴伺服器。它適合小型專案和靜態網站。

fuse.js 的 README

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.