Lunr.js logo

Lunr.js

Client-side full-text search library for fast, offline queries

Lunr.js provides a lightweight, browser‑based full‑text search engine that indexes JSON documents, supports multiple languages, field boosting, fuzzy matching, and works without server calls.

Lunr.js banner

Overview

Overview

Lunr.js is a compact JavaScript library that brings full‑text search capabilities directly into the browser. It indexes JSON documents on the client, allowing instant retrieval of relevant results without any network latency. The library is designed for modern browsers and can be added via a script tag or npm package.

Who It Serves & How It Works

Ideal for static sites, single‑page applications, and offline‑first web apps, Lunr.js lets developers define searchable fields, boost terms or whole documents, and perform fuzzy queries with wildcards or edit distance. Because the index lives in memory, searches are instantaneous, and the same code runs in any environment that supports ES5 (or a shim). Deployment is as simple as including the script and building the index during page load.

Limitations & Extensibility

While powerful for client‑side scenarios, Lunr.js is not suited for massive datasets that exceed browser memory limits, nor does it provide built‑in persistence. For larger scale needs, a server‑side search engine would be more appropriate.

Highlights

Full‑text search support for 14 languages
Boost terms at query time or whole documents at index time
Scope searches to specific fields
Fuzzy matching with wildcards and edit distance

Pros

  • Runs entirely in the browser, eliminating server dependencies
  • Zero network latency; works offline
  • Simple, expressive API that is easy to integrate
  • Multilingual indexing out of the box

Considerations

  • Limited to client‑side memory; large indexes can be impractical
  • No built‑in persistence; index must be rebuilt on each load
  • Feature set is smaller than enterprise search platforms
  • Requires ES5 support or a shim for older browsers

Managed products teams compare with

When teams consider Lunr.js, these hosted platforms usually appear on the same shortlist.

Algolia logo

Algolia

Hosted search-as-a-service platform delivering real-time, full-text search for apps and websites

Amazon CloudSearch logo

Amazon CloudSearch

Managed search service to index and query text & structured data

Amazon Kendra logo

Amazon Kendra

AI-powered enterprise search service that indexes and searches across various content repositories with natural language queries

Looking for a hosted option? These are the services engineering teams benchmark against before choosing open source.

Fit guide

Great for

  • Static sites that need client‑side search
  • Single‑page applications with data already in the browser
  • Offline‑first web apps
  • Prototypes or demos where quick search is needed

Not ideal when

  • Huge corpora requiring server‑side scaling
  • Real‑time indexing of streaming data
  • Complex faceted search or analytics
  • Environments lacking ES5 support without shims

How teams use it

Documentation site search

Visitors locate API pages instantly without server queries

E‑commerce product catalog

Customers filter products client‑side, reducing server load

Blog archive

Readers perform fuzzy searches across posts even when offline

Educational app

Students search lesson content locally, ensuring access without internet

Tech snapshot

JavaScript94%
HTML4%
Makefile1%
Shell1%
CSS1%

Tags

lunrsearchfull-text-searchjavascript

Frequently asked questions

Can Lunr.js replace a server‑side search engine?

It works well for small to medium client datasets but is not designed for large, scalable search workloads.

How is the search index created?

You define fields and add JSON documents via the provided API; the library builds an in‑memory inverted index.

Does Lunr.js support persistence?

No built‑in persistence; you must serialize and store the index yourself if needed.

What browsers are supported?

All modern browsers; older browsers need an ES5 shim such as Augment.js or ES5‑Shim.

Is the library licensed for commercial use?

Yes, it is released under the MIT license.

Project at a glance

Dormant
Stars
9,187
Watchers
9,187
Forks
559
LicenseMIT
Repo age14 years old
Last commitlast year
Primary languageJavaScript

Last synced yesterday