Library / SDK
nextapps-de/flexsearch avatar
nextapps-de/flexsearch

FlexSearch: High-Speed Full-Text Search for Browser and Node.js

Next-generation full-text search library for Browser and Node.js

13,802 stars524 forksJavaScriptApache-2.0

At a glance

What is it?
FlexSearch is a JavaScript full-text search library that runs in browsers and Node.js, claiming the fastest in-memory query throughput of any comparable JavaScript library, with v0.8 adding persistent index backends including Redis, Postgres, SQLite, MongoDB, and Clickhouse.
Who is it for?
FlexSearch is the right choice when you need client-side or server-side full-text search without a dedicated search cluster, and your data fits a schema that benefits from workers and phonetic matching. It is the wrong fit when you need production-grade relevance ranking with BM25 scoring, deep analytics, or a managed service with SLAs.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 93 days ago.
What is it written in?
Mainly JavaScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What FlexSearch Solves and Who Benefits

FlexSearch targets two populations: web developers building search into a browser-based application without a backend search service, and Node.js developers who need fast, in-process text search without deploying Elasticsearch or a similar server. Both populations care about memory footprint and query latency, because search that slows down a page or a request pipeline loses value quickly.

The benchmark numbers in the README illustrate the positioning. For single-term queries, FlexSearch records 50,955,718 operations per second in its own benchmark against a set of comparable libraries. Lunr, one of the more established JavaScript search libraries, reaches 11,527. MiniSearch records 30,589; Orama 29,445. The memory column shows FlexSearch at 16 units compared to MiniSearch at 4,777 and Orama at 5,355. The README links to the benchmark source at nextapps-de.github.io/flexsearch so the methodology can be examined.

FlexSearch is not a replacement for Elasticsearch or Apache Solr when you need distributed search across large document sets, faceted filtering, or complex relevance tuning. It is an in-process library that trades server complexity for lower control over ranking.

Core Capabilities: Phonetic Matching, Tag Search, and Workers

FlexSearch goes beyond simple substring matching. The library supports phonetic transformations, which let queries match words that sound like the search term even when spelled differently. Partial matching catches prefixes and substrings. Tag search allows attaching metadata labels to documents and filtering results by tag without a separate index pass.

Result highlighting marks the matched portions of returned content so the UI can render them without a second pass over the text. The suggestion feature returns candidate completions as the user types, suitable for autocomplete dropdowns. Multi-field document search means a single query can target multiple fields of a structured record and merge results with configurable weights.

For large workloads, FlexSearch uses Web Workers in the browser and Node.js worker threads to push index updates and queries to dedicated background threads. This prevents a search operation from blocking the main event loop. The README describes this as balancing work across dedicated threads rather than running everything synchronously. The README also notes that the library supports CJK characters (Chinese, Korean, Japanese), Hindi, Arabic, Cyrillic, Greek and Coptic, and Hebrew in addition to Latin-script languages.

Installing FlexSearch and Loading It in Node.js or a Browser

FlexSearch is distributed as an npm package named flexsearch. Install it for a Node.js project with:

bash
npm install flexsearch

The package exports two module formats from its dist directory. The ESM entry point is `dist/flexsearch.bundle.module.min.mjs`, and the CommonJS entry point is `dist/flexsearch.bundle.min.js`. For browser use without a bundler, the README points to example files in the repository's example/ directory, including a browser-legacy example and a browser-module example using native ES modules.

Persistent index backends are exported as separate sub-paths. The package.json exports map `./db/*` to `dist/module/db/*/index.js` for ESM and `dist/db/*/index.cjs` for CommonJS. For the Redis adapter, the connection is configured through the adapter's options rather than through the main FlexSearch constructor, keeping the connection concern separate from the index definition.

Language-specific encoders for non-Latin scripts are loaded separately via the `./lang/*` export path, so a Latin-only application does not pay the cost of loading Arabic or CJK encoding tables.

Persistent Indexes in v0.8: Running the Backends

Version 0.8 introduced Persistent Indexes, which store the index data in an external database instead of keeping it only in memory. This makes FlexSearch viable for applications where the document set is too large to hold in RAM, or where the index needs to survive process restarts without a full re-index.

The supported backends are IndexedDB (for browser-side persistence), Redis, SQLite, Postgres, MongoDB, and Clickhouse. The repository includes a docker-compose.yml to start all the server-side backends at once for local development:

yaml
services:
  postgres:
    image: postgres:latest
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    ports:
      - "5432:5432"
    container_name: flexsearch_postgres_db
  redis:
    image: redislabs/rejson:latest
    ports:
      - "6379:6379"
    container_name: flexsearch_redis_db

The README describes the persistent index as "well optimized for scaling of large datasets and running in parallel." It also notes that all features were natively ported into the database engines, meaning the phonetic transformations, tag search, and highlighting work with the persistent backends, not only with the in-memory default.

Limitations and Cases Where FlexSearch Is the Wrong Tool

FlexSearch does not provide a relevance ranking model comparable to TF-IDF or BM25 in the way that a full search engine does. The benchmark table measures throughput and memory, not ranking quality. If the accuracy of result ordering matters more than raw query speed, a library that implements a scoring model may produce better results.

The persistent backends are external services, which adds operational overhead. A Postgres or MongoDB deployment requires ongoing management, backup, and capacity planning. For a small application, running a database just to hold a search index may be disproportionate. The in-memory mode is simpler but loses its state on process restart and is limited by available RAM.

Worker support, which distributes query load across threads, is powerful but adds asynchronous complexity. Applications that currently call search synchronously need to adapt to a Promise-based interface when enabling workers.

The library's license is Apache-2.0, which is permissive for commercial use but carries patent grant language that teams should be aware of. The README does not document rollback procedures when migrating between index schema versions.

FlexSearch's resolver API, listed as a documented feature in the README's navigation links, handles complex query composition where multiple conditions need to be combined. The README does not detail whether the resolver works transparently across all persistent backends or only with the in-memory default. Teams relying on advanced query composition with a Postgres or MongoDB backend should test that behavior before deployment.

The README links to a live autocomplete demo at the repository's GitHub Pages URL, which demonstrates the kind of instant-results interface that FlexSearch targets. That demo is a useful starting reference for integrating the suggestion feature into a search input.

FlexSearch vs Lunr and MiniSearch

Lunr is the JavaScript search library most commonly referenced in comparisons with FlexSearch. Lunr builds an inverted index at index time using TF-IDF scoring and provides a query language for field boosts and fuzzy matching. Its design is stable and well-documented, but throughput in the FlexSearch benchmark is approximately 4,400 times lower for single-term queries. Lunr does not support persistent backends, workers, or phonetic matching without additional plugins.

MiniSearch focuses on relevance ranking with a smaller footprint than a full-text search server. It supports fuzzy matching, prefix matching, and field boosting. The FlexSearch benchmark shows MiniSearch at 30,589 operations per second and 4,777 memory units, compared to FlexSearch's 50,955,718 and 16. MiniSearch's design prioritizes correctness of ranking over raw throughput.

For applications where relevance ranking is the primary concern and the document set is small, Lunr or MiniSearch may be simpler to configure. FlexSearch is the better choice when you need maximum query throughput, multilingual content, or persistent index storage in a database you already operate.

Editorial conclusion

FlexSearch is the right choice when you need client-side or server-side full-text search without a dedicated search cluster, and your data fits a schema that benefits from workers and phonetic matching. It is the wrong fit when you need production-grade relevance ranking with BM25 scoring, deep analytics, or a managed service with SLAs. Evaluate the persistent index backends using the provided docker-compose.yml before committing to Postgres or MongoDB as your index store, since those adapters depend on external services that add operational complexity. The library is under active development; the last push to the repository was on 2026-06-28.

Frequently asked questions

What is FlexSearch?

FlexSearch is a JavaScript full-text search library for browsers and Node.js. It provides fast in-memory search with optional persistent index storage in databases like Redis, Postgres, SQLite, MongoDB, and Clickhouse.

How does FlexSearch compare to other JavaScript search libraries?

FlexSearch's own benchmark shows it reaching over 50 million single-term queries per second in memory, compared to roughly 30,000 for MiniSearch and 11,000 for Lunr. FlexSearch uses less memory per query but offers less built-in relevance scoring than those alternatives.

Does FlexSearch work with IndexedDB for browser-side persistence?

Yes. FlexSearch v0.8 added IndexedDB as a persistent index backend for browser applications. Server-side backends include Redis, Postgres, SQLite, MongoDB, and Clickhouse.

Official sources

  1. Issues
  2. License: Apache-2.0
  3. nextapps-de/flexsearch on GitHub
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/nextapps-de-flexsearch.svg)](https://hysenlabs.com/projects/nextapps-de-flexsearch)