lunr vs minisearch vs flexsearch
Local full-text search with FlexSearch, Lunr and MiniSearch
lunrminisearchflexsearch

Local full-text search with FlexSearch, Lunr and MiniSearch

These JavaScript libraries build local search indexes rather than providing a hosted search service. They differ in indexing models, query features, update workflows and available execution options. The useful comparison depends on the document collection and queries the application needs to support.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
lunr9,703,1789,201-1306 years agoMIT
minisearch6,438,1656,209827 kB14a year agoMIT
flexsearch1,294,04713,8252.33 MB40a year agoApache-2.0

Index design and query behavior

FlexSearch offers an Index for text associated with identifiers and a Document model for multiple fields. Tokenization, encoding and query options influence matching behavior. Worker indexes and persistence adapters are separate integration choices, not automatic properties of every ordinary index instance.

Lunr configures fields and adds documents through its builder. Searches return references, scores and match information; application document content remains a separate concern. Its query language can express field restrictions, boosts, wildcards and edit-distance terms. Plan how the index is built and replaced when documents change.

MiniSearch accepts configured searchable fields and optional stored fields. Documents can be added and removed after construction, and results can include stored application data. Prefix search, fuzzy matching and auto-suggestions are configurable features; their defaults and scoring should not be assumed to match another engine.

Evaluate the application's actual language and data

Use representative documents, spelling variations and query patterns to judge relevance. An engine's score is not a probability and cannot be compared numerically with another library's score. Tokenization and language processing matter especially for text that does not follow the default word boundaries.

Measure index construction, query latency and memory with the chosen configuration rather than repeating a vendor benchmark as a universal ranking. All three remain application libraries: UI state, data synchronization and deployment of any prebuilt index need their own implementation.

How to Choose: lunr vs minisearch vs flexsearch

  • lunr:

    Choose it for a build-then-query full-text index with field configuration, query syntax and serializable indexes. Its returned references need to be mapped back to application documents.

  • minisearch:

    Choose it for an in-memory document index with runtime additions/removals, configurable prefix and fuzzy matching, stored result fields and query suggestions.

  • flexsearch:

    Choose it when configurable tokenization, document indexes and the available worker or persistence integrations match the workload. Select the appropriate index and build instead of assuming every feature is active by default.

README for lunr

Lunr.js

Join the chat at https://gitter.im/olivernn/lunr.js

Build Status

A bit like Solr, but much smaller and not as bright.

Example

A very simple search index can be created using the following:

var idx = lunr(function () {
  this.field('title')
  this.field('body')

  this.add({
    "title": "Twelfth-Night",
    "body": "If music be the food of love, play on: Give me excess of it…",
    "author": "William Shakespeare",
    "id": "1"
  })
})

Then searching is as simple as:

idx.search("love")

This returns a list of matching documents with a score of how closely they match the search query as well as any associated metadata about the match:

[
  {
    "ref": "1",
    "score": 0.3535533905932737,
    "matchData": {
      "metadata": {
        "love": {
          "body": {}
        }
      }
    }
  }
]

API documentation is available, as well as a full working example.

Description

Lunr.js is a small, full-text search library for use in the browser. It indexes JSON documents and provides a simple search interface for retrieving documents that best match text queries.

Why

For web applications with all their data already sitting in the client, it makes sense to be able to search that data on the client too. It saves adding extra, compacted services on the server. A local search index will be quicker, there is no network overhead, and will remain available and usable even without a network connection.

Installation

Simply include the lunr.js source file in the page that you want to use it. Lunr.js is supported in all modern browsers.

Alternatively an npm package is also available npm install lunr.

Browsers that do not support ES5 will require a JavaScript shim for Lunr to work. You can either use Augment.js, ES5-Shim or any library that patches old browsers to provide an ES5 compatible JavaScript environment.

Features

  • Full text search support for 14 languages
  • Boost terms at query time or boost entire documents at index time
  • Scope searches to specific fields
  • Fuzzy term matching with wildcards or edit distance

Contributing

See the CONTRIBUTING.md file.