# JavaScript full-text search libraries

JavaScript search libraries find matching records in a list of objects or documents without a search server. These libraries add search boxes to documentation sites, product catalogs, and offline apps that run entirely in the browser.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Fuse.js](#fuse-js) | 76.1M | 20.5K | Jul 2026 | Apache-2.0 |
| [Lunr](#lunr) | 37.2M | 9.2K | Aug 2020 | MIT |
| [MiniSearch](#minisearch) | 23.4M | 6.2K | Sep 2025 | MIT |
| [Orama](#orama) | 7.9M | 10.6K | Dec 2025 | Apache-2.0 |
| [FlexSearch](#flexsearch) | 5.3M | 13.8K | Sep 2025 | Apache-2.0 |
| [Js Search](#js-search) | 849.5K | 2.2K | May 2023 | MIT |
| [wink-bm25-text-search](#wink-bm25-text-search) | 277.9K | 74 | Nov 2022 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Fuse.js](#fuse-js) has the most installs and the most GitHub stars.

## Capabilities

| Library | Add documents after indexing | Bundled TypeScript declarations | Index serialization | Prefix search | Fuzzy matching |
| --- | --- | --- | --- | --- | --- |
| [Fuse.js](#fuse-js) | Yes | Yes | Yes | Yes | Yes |
| [Lunr](#lunr) | No | No | Yes | Yes | Yes |
| [MiniSearch](#minisearch) | Yes | Yes | Yes | Yes | Yes |
| [Orama](#orama) | Yes | Yes | Yes | Yes | Yes |
| [FlexSearch](#flexsearch) | Yes | Yes | Yes | Yes | Yes |
| [Js Search](#js-search) | Yes | No | Undocumented | Yes | Undocumented |
| [wink-bm25-text-search](#wink-bm25-text-search) | No | No | Yes | Undocumented | Undocumented |

## Libraries

### Fuse.js

[GitHub](https://github.com/krisk/Fuse) · [npm](https://www.npmjs.com/package/fuse.js) · [Docs](https://github.com/krisk/Fuse/blob/main/README.md)

Fuse.js is a fuzzy search library for small to medium datasets searched in the browser or on a server, with no dependencies. `new Fuse` takes an array of strings or objects and a `keys` list of fields to search. Calling `search` returns the matching items ranked by score. Matching uses the Bitap algorithm, an approximate string matcher, so queries with typos, misspellings, or partial words still find results. With `useTokenSearch` turned on, multi-word queries are ranked by relevance across all their words.

- Downloads / mo: 76.1M
- Stars: 20.5K
- Last release: 7.5.0
- License: Apache-2.0
- Capabilities: [From the Fuse.js docs](https://github.com/krisk/Fuse/blob/main/README.md)

**Strengths**

- **Tolerates typos.** Finds near matches when the query has typos, swapped letters, or missing characters.
- **Weights fields.** Give title matches more weight than description matches.

**Watch out for**

- **No index.** Every search compares the query with every item. For larger datasets, `FuseWorker` splits the data across web workers, and an indexed library such as [MiniSearch](#minisearch) avoids the full scan.
- **Worker limits.** `FuseWorker` can't take function-valued options, such as `sortFn` or `getFn`, because functions can't move to a worker.

```sh
npm install fuse.js
```

**mantinedev/mantine** (31.9K stars)

[mantinedev/mantine](https://github.com/mantinedev/mantine) 

```javascript
const fuzzySearchFilter: SpotlightFilterFunction = (query, actions) => {
  if (!query.trim()) {
    return actions;
  }

  const flatActions = actions.reduce<any[]>((acc, item) => {
    if ('actions' in item) {
      return [...acc, ...item.actions.map((action) => ({ ...action, group: item.group }))];
    }
    return [...acc, item];
  }, []);

  const fuse = new Fuse(flatActions, {
    keys: ['label', 'description', 'keywords'],
    threshold: 0.3,
    minMatchCharLength: 1,
  });

  const results = fuse.search(query).map((result) => result.item);

  const groups: Record<string, any> = {};
  const result: any[] = [];

  results.forEach((action) => {
    if (action.group) {
      if (!groups[action.group]) {
        groups[action.group] = { pushed: false, data: { group: action.group, actions: [] } };
      }
      groups[action.group].data.actions.push(action);
      if (!groups[action.group].pushed) {
        groups[action.group].pushed = true;
        result.push(groups[action.group].data);
      }
    } else {
      result.push(action);
    }
  });

  return result;
};

```

[apps/mantine.dev/src/components/Search/Search.tsx](https://github.com/mantinedev/mantine/blob/3646de9f0fe83eaf2946154e6385bd82eb15c243/apps/mantine.dev/src/components/Search/Search.tsx#L9-L48) · [More projects using Fuse.js →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20projects%20using%20fuse.js%20for%20grouped%20IDE%20search%2C%20documentation%20section%20indexing%20and%20static%20search-index%20generation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import Fuse from 'fuse.js'
const books = [
  { title: "Old Man's War", author: 'John Scalzi' },
  { title: 'The Lock Artist', author: 'Steve Hamilton' }
]
const fuse = new Fuse(books, {
  keys: ['title', 'author']
})
const results = fuse.search('jon')

```

From [getting-started.md](https://github.com/krisk/Fuse/blob/main/docs/getting-started.md)

### Lunr

[GitHub](https://github.com/olivernn/lunr.js) · [npm](https://www.npmjs.com/package/lunr) · [Docs](https://lunrjs.com/guides/index_prebuilding.html)

Lunr builds a full-text search index of JSON documents in the browser. A `lunr` call takes a function that declares the fields, such as `title` and `body`, and adds each document. Searching with `idx.search` returns matching document references, each with a relevance score and the terms that matched. Indexes serialize to JSON. A site can build its index at deploy time and load the result in the browser instead of indexing on every visit. Queries can boost terms, scope to single fields, or match with wildcards and edit distance. Language support covers fourteen languages.

- Downloads / mo: 37.2M
- Stars: 9.2K
- Last release: 2.3.9
- License: MIT
- Capabilities: [From the Lunr docs](https://lunrjs.com/guides/index_prebuilding.html)

**Strengths**

- **Prebuilt indexes.** Build the index during the site build and serve the serialized index to the browser.
- **Field boosts.** Boost a field at build time so its matches rank higher.

**Watch out for**

- **Immutable indexes.** After an index is built, documents can't be added, updated, or removed. Changing the documents means rebuilding the index.
- **Wildcards skip stemming.** A search term with a wildcard isn't stemmed. The term matches only its literal form.

```sh
npm install lunr
```

**cmfcmf/docusaurus-search-local** (503 stars)

[cmfcmf/docusaurus-search-local](https://github.com/cmfcmf/docusaurus-search-local) 

```javascript
function () {
              if (language !== "en") {
                if (Array.isArray(language)) {
                  // @ts-expect-error
                  this.use(lunr.multiLanguage(...language));
                } else {
                  // @ts-expect-error
                  this.use(lunr[language]);
                }
              }

              this.k1(k1);
              this.b(b);

              this.ref("id");
              this.field("title");
              this.field("content");
              this.field("tags");

              if (indexDocSidebarParentCategories > 0) {
                this.field("sidebarParentCategories");
              }
              const that = this;
              documents.forEach(
                ({
                  id,
                  sectionTitle,
                  sectionContent,
                  sectionTags,
                  docSidebarParentCategories,
                }) => {
                  let sidebarParentCategories;
                  if (
                    indexDocSidebarParentCategories > 0 &&
                    docSidebarParentCategories
                  ) {
                    sidebarParentCategories = [...docSidebarParentCategories]
                      .reverse()
                      .slice(0, indexDocSidebarParentCategories)
                      .join(" ");
                  }

                  that.add({
                    id: id.toString(), // the ref must be a string
                    title: sectionTitle,
                    content: sectionContent,
                    tags: sectionTags,
                    sidebarParentCategories,
                  });
                },
              );
            }

```

[packages/docusaurus-search-local/src/server/index.ts](https://github.com/cmfcmf/docusaurus-search-local/blob/3e094559f8d46bb53660c8992a485f3b6e5e96d7/packages/docusaurus-search-local/src/server/index.ts#L517-L568) · [More projects using Lunr →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20projects%20using%20lunr%20for%20grouped%20IDE%20search%2C%20documentation%20section%20indexing%20and%20static%20search-index%20generation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
var documents = [{
  "name": "Lunr",
  "text": "Like Solr, but much smaller, and not as bright."
}, {
  "name": "React",
  "text": "A JavaScript library for building user interfaces."
}, {
  "name": "Lodash",
  "text": "A modern JavaScript utility library delivering modularity, performance & extras."
}]
var idx = lunr(function () {
  this.ref('name')
  this.field('text')
  documents.forEach(function (doc) {
    this.add(doc)
  }, this)
})
idx.search("bright")

```

From [getting_started.html](https://lunrjs.com/guides/getting_started.html)

### MiniSearch

[GitHub](https://github.com/lucaong/minisearch) · [npm](https://www.npmjs.com/package/minisearch) · [Docs](https://github.com/lucaong/minisearch/blob/master/README.md)

MiniSearch keeps a full-text index in memory, in the browser or in Node.js, with no external dependencies. `new MiniSearch` lists the fields to index and the fields to return with results. After `addAll` loads the documents, `search` supports exact, prefix, and fuzzy matching with field boosts. A separate method, `autoSuggest`, completes partial queries for search as the user types. Unlike [Lunr](#lunr), MiniSearch lets documents be added and removed at any time.

- Downloads / mo: 23.4M
- Stars: 6.2K
- Last release: 7.2.0
- License: MIT
- Capabilities: [From the MiniSearch docs](https://github.com/lucaong/minisearch/blob/master/README.md)

**Strengths**

- **Prefix and fuzzy search.** Supports prefix search, fuzzy search, ranking, and field boosts in one index.
- **Saves indexes as JSON.** Serialize the index to JSON and reload it later with MiniSearch.loadJSON.

**Watch out for**

- **Index in memory.** The index is stored in process memory. The indexed data has to fit in that memory.
- **Custom stemming.** Stemming and stop words come from a `processTerm` function the project supplies.

```sh
npm install minisearch
```

**vuejs/vitepress** (18.5K stars)

[vuejs/vitepress](https://github.com/vuejs/vitepress) 

```javascript
async function indexFile(page: string) {
    const file = path.join(siteConfig.srcDir, page)
    // get file metadata
    const fileId = getDocId(file)
    const locale = getLocaleForPath(
      siteConfig.site,
      siteConfig.rewrites.map[page] || page
    )
    const index = getIndexByLocale(locale)
    // retrieve file and split into "sections"
    let html: string
    try {
      html = await render(file, locale)
    } catch (e) {
      // in dev this runs unawaited, so a page that fails to render must not
      // reject and take the server down with it — the page reports the error
      // itself through the markdown transform
      siteConfig.logger.warn(
        c.yellow(`Failed to index ${page} for search: ${(e as Error).message}`)
      )
      return
    }
    if (!html) return
    const sections =
      // user provided generator
      (await options.miniSearch?._splitIntoSections?.(file, html)) ??
      // default implementation
      splitPageIntoSections(html)
    // add sections to the locale index
    for await (const section of sections) {
      if (!section || !(section.text || section.titles)) break
      const { anchor, text, titles } = section
      const id = anchor ? [fileId, anchor].join('#') : fileId
      index.has(id) && index.discard(id)
      index.add({
        id,
        text,
        title: titles.at(-1)!,
        titles: titles.slice(0, -1)
      })
    }
  }

```

[src/node/plugins/localSearchPlugin.ts](https://github.com/vuejs/vitepress/blob/40b2e090772ac11eac358d25ec92ee435fc2adbd/src/node/plugins/localSearchPlugin.ts#L144-L185) · [More projects using MiniSearch →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20projects%20using%20minisearch%20for%20grouped%20IDE%20search%2C%20documentation%20section%20indexing%20and%20static%20search-index%20generation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import MiniSearch from 'minisearch'
const documents = [
  {
    id: 1,
    title: 'Moby Dick',
    text: 'Call me Ishmael. Some years ago...',
    category: 'fiction'
  },
  {
    id: 2,
    title: 'Zen and the Art of Motorcycle Maintenance',
    text: 'I can see by my watch...',
    category: 'fiction'
  },
  {
    id: 3,
    title: 'Neuromancer',
    text: 'The sky above the port was...',
    category: 'fiction'
  },
  {
    id: 4,
    title: 'Zen and the Art of Archery',
    text: 'At first sight it must seem...',
    category: 'non-fiction'
  },
]
let miniSearch = new MiniSearch({
  fields: ['title', 'text'], // fields to index for full-text search
  storeFields: ['title', 'category'] // fields to return with search results
})
miniSearch.addAll(documents)
let results = miniSearch.search('zen art motorcycle')

```

From [README.md](https://github.com/lucaong/minisearch/blob/master/README.md)

### Orama

[GitHub](https://github.com/oramasearch/orama) · [npm](https://www.npmjs.com/package/@orama/orama) · [Docs](https://raw.githubusercontent.com/oramasearch/docs/refs/heads/main/content/docs/orama-js/index.mdx)

Orama is a search engine that runs in the browser, on a server, or at the edge, with full-text, vector, and hybrid search in one database. `create` sets a schema of typed fields. Documents go in through `insert`. A `search` call with a `term` returns ranked hits. Setting `mode` to `vector` compares a query embedding with a vector field instead. Filters, facets, geosearch, typo tolerance, and stemming in thirty languages come built in.

- Downloads / mo: 7.9M
- Stars: 10.6K
- Last release: 3.1.18
- License: Apache-2.0
- Capabilities: [From the Orama docs](https://raw.githubusercontent.com/oramasearch/docs/refs/heads/main/content/docs/orama-js/index.mdx)

**Strengths**

- **Field boosts.** Boost a field so its matches rank higher.
- **Vector search built in.** Vector, full-text, and hybrid queries use the same search function.

**Watch out for**

- **Embeddings from outside.** Vector queries need embeddings at insert and search time, from the project's own model or from the `@orama/plugin-embeddings` plugin.
- **Fixed vector size.** Each vector field declares its dimension count when the database is created.

```sh
npm install @orama/orama
```

**fuma-nama/fumadocs** (13.7K stars)

[fuma-nama/fumadocs](https://github.com/fuma-nama/fumadocs) 

```javascript
export async function createDBSimple({
  indexes,
  tokenizer,
  ...rest
}: SimpleOptions): Promise<Orama<typeof simpleSchema>> {
  const items = typeof indexes === 'function' ? await indexes() : indexes;
  const db = create({
    schema: simpleSchema,
    ...rest,
    components: {
      ...rest.components,
      tokenizer: tokenizer ?? rest.components?.tokenizer,
    },
  }) as Orama<typeof simpleSchema>;

  await insertMultiple(
    db,
    items.map((page) => ({
      title: page.title,
      description: page.description,
      url: page.url,
      content: page.content,
      keywords: page.keywords,
    })),
  );

  return db;
}

```

[packages/core/src/search/orama/create-db.ts](https://github.com/fuma-nama/fumadocs/blob/9e16ce6ede74c5c506ed1424840ac26fa8cb0cf5/packages/core/src/search/orama/create-db.ts#L99-L126) · [More projects using Orama →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20projects%20using%20%40orama/orama%20for%20grouped%20IDE%20search%2C%20documentation%20section%20indexing%20and%20static%20search-index%20generation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import { create, search, insert } from "@orama/orama";
const db = create({
  schema: {
    name: "string",
    description: "string",
    price: "number",
    meta: {
      rating: "number",
    },
  },
});
insert(db, {
  name: "Wireless Headphones",
  description: "Experience immersive sound quality with these noise-cancelling wireless headphones.",
  price: 99.99,
  meta: {
    rating: 4.5,
  },
});
const searchResult = search(db, {
  term: "headphones",
});

```

From [index.mdx](https://raw.githubusercontent.com/oramasearch/docs/refs/heads/main/content/docs/orama-js/index.mdx)

### FlexSearch

[GitHub](https://github.com/nextapps-de/flexsearch) · [npm](https://www.npmjs.com/package/flexsearch) · [Docs](https://github.com/nextapps-de/flexsearch/blob/master/README.md)

FlexSearch builds full-text indexes for the browser and Node.js. Three index types cover different jobs: `Index` stores id and text pairs, `Document` indexes multi-field JSON documents, and `Worker` runs an index in a background thread. The `tokenize` option sets how partial words match. With `forward`, a query for `flex` finds flexsearch, while `full` indexes every substring at a much higher memory cost. Indexes stay in memory by default, and persistent indexes can store them in IndexedDB, Redis, SQLite, Postgres, MongoDB, or ClickHouse.

- Downloads / mo: 5.3M
- Stars: 13.8K
- Last release: 0.8.212
- License: Apache-2.0
- Capabilities: [From the FlexSearch docs](https://github.com/nextapps-de/flexsearch/blob/master/README.md)

**Strengths**

- **Tokenizer controls matching.** Choose a tokenizer so that typing flex or search finds flexsearch.
- **Worker threads.** Run index updates and queries in parallel worker threads.

**Watch out for**

- **Tokenizer sets memory.** Broader partial matching multiplies index size. The README recommends the narrowest tokenizer that covers the queries users type.
- **Async workers.** Every method on a `Worker` index returns a promise or takes a callback.

```sh
npm install flexsearch
```

**TryGhost/Ghost** (55.8K stars)

[TryGhost/Ghost](https://github.com/TryGhost/Ghost) 

```javascript
export function createFlexSearchProvider(sources: readonly SearchSource[]): SearchProvider {
  const indexes = sources.map((source) => {
    const index = new FlexSearch.Document<SearchItem>({
      tokenize: 'forward',
      document: { id: 'id', index: ['title', 'keywords'] },
    });
    source.items.forEach((item) => index.add(item));
    return { index, itemsById: new Map(source.items.map((item) => [item.id, item])) };
  });

  return {
    search(term) {
      return groupResults(sources, (_source, sourceIndex) => {
        const { index, itemsById } = indexes[sourceIndex];
        const ids = new Set(
          index.search(term, RESULT_LIMIT).flatMap((field) => field.result.map(String)),
        );

        return [...ids].flatMap((id) => itemsById.get(id) ?? []);
      });
    },
  };
}

```

[apps/admin/src/global-search/search-providers.ts](https://github.com/TryGhost/Ghost/blob/ea95c7b4ac7e6d76418764a69b65032a8b965a53/apps/admin/src/global-search/search-providers.ts#L27-L49) · [More projects using FlexSearch →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20projects%20using%20flexsearch%20for%20grouped%20IDE%20search%2C%20documentation%20section%20indexing%20and%20static%20search-index%20generation&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import { Index } from "flexsearch";
const index = new Index({
    tokenize: "forward"
});
const data = [
    'cats abcd efgh ijkl mnop qrst uvwx cute',
    'cats abcd efgh ijkl mnop qrst cute',
    'cats abcd efgh ijkl mnop cute',
    'cats abcd efgh ijkl cute',
    'cats abcd efgh cute',
    'cats abcd cute',
    'cats cute'
];
data.forEach((item, id) => {
    index.add(id, item);
});
const result = index.search("cute cat");

```

From [index.js](https://github.com/nextapps-de/flexsearch/blob/master/example/nodejs-esm/basic/index.js)

### Js Search

[GitHub](https://github.com/bvaughn/js-search) · [npm](https://www.npmjs.com/package/js-search) · [Docs](https://raw.githubusercontent.com/bvaughn/js-search/master/README.md)

Js Search indexes JavaScript and JSON objects for client-side search, with no third-party dependencies. `new JsSearch.Search` takes the field that identifies each document. Next, `addIndex` adds each field to search, including nested ones such as an author's name, and `addDocuments` loads the objects. Results rank by TF-IDF, a term-weighting score, unless the project switches to an unordered index. The index strategy sets what matches: word prefixes by default, exact words, or every substring. The library began as a lighter implementation of [Lunr](#lunr).

- Downloads / mo: 849.5K
- Stars: 2.2K
- Last release: 2.0.1
- License: MIT
- Capabilities: [From the Js Search docs](https://raw.githubusercontent.com/bvaughn/js-search/master/README.md)

**Strengths**

- **Choice of index strategy.** Index word prefixes by default, or switch to exact words or every substring.
- **No dependencies.** It runs on ES5 and needs no third-party libraries.

**Watch out for**

- **Stemming from another library.** Stemming comes from a third-party stemmer, such as porter-stemmer, wrapped in a `StemmingTokenizer`.
- **Ranking costs time.** Switching to `UnorderedSearchIndex` turns off TF-IDF ranking and returns results in no particular order.

```sh
npm install js-search
```

**gatsbyjs/gatsby** (55.9K stars)

[gatsbyjs/gatsby](https://github.com/gatsbyjs/gatsby) 

```javascript
rebuildIndex = () => {
    const { bookList } = this.state

    const dataToSearch = new JsSearch.Search(`isbn`)

    /**
     *  defines a indexing strategy for the data
     * more more about it in here https://github.com/bvaughn/js-search#configuring-the-index-strategy
     */
    dataToSearch.indexStrategy = new JsSearch.PrefixIndexStrategy()

    /**
     * defines the sanitizer for the search
     * to prevent some of the words from being excluded
     *
     */
    dataToSearch.sanitizer = new JsSearch.LowerCaseSanitizer()

    /**
     * defines the search index
     * read more in here https://github.com/bvaughn/js-search#configuring-the-search-index
     */
    dataToSearch.searchIndex = new JsSearch.TfIdfSearchIndex(`isbn`)

    dataToSearch.addIndex(`title`) // sets the index attribute for the data
    dataToSearch.addIndex(`author`) // sets the index attribute for the data

    dataToSearch.addDocuments(bookList) // adds the data to be searched
    this.setState({ search: dataToSearch, isLoading: false })
  }

```

[examples/using-js-search/src/components/SearchContainer.js](https://github.com/gatsbyjs/gatsby/blob/0ac6c88a72c4dfd4d541e3ac43c664343e8e15b6/examples/using-js-search/src/components/SearchContainer.js#L35-L64) · [More projects using Js Search →](https://dashboard.exa.ai/playground/search?q=js-search%20GitHub%20projects)

**Quickstart**

```javascript
import * as JsSearch from 'js-search';
var theGreatGatsby = {
  isbn: '9781597226769',
  title: 'The Great Gatsby',
  author: {
    name: 'F. Scott Fitzgerald'
  },
  tags: ['book', 'inspirational']
};
var theDaVinciCode = {
  isbn: '0307474275',
  title: 'The DaVinci Code',
  author: {
    name: 'Dan Brown'
  },
  tags: ['book', 'mystery']
};
var angelsAndDemons = {
  isbn: '074349346X',
  title: 'Angels & Demons',
  author: {
    name: 'Dan Brown',
  },
  tags: ['book', 'mystery']
};
var search = new JsSearch.Search('isbn');
search.addIndex('title');
search.addIndex(['author', 'name']);
search.addIndex('tags')
search.addDocuments([theGreatGatsby, theDaVinciCode, angelsAndDemons]);
search.search('The');    // [theGreatGatsby, theDaVinciCode]

```

From [README.md](https://raw.githubusercontent.com/bvaughn/js-search/master/README.md)

### wink-bm25-text-search

[GitHub](https://github.com/winkjs/wink-bm25-text-search) · [npm](https://www.npmjs.com/package/wink-bm25-text-search) · [Docs](https://raw.githubusercontent.com/winkjs/wink-bm25-text-search/master/README.md)

wink-bm25-text-search builds an in-memory search index from JSON documents, in Node.js or the browser, ranked by a probabilistic relevance algorithm. `defineConfig` sets a weight for each field. Next, `definePrepTasks` sets the text preparation, such as tokenizing and stemming with wink-nlp, and `addDoc` adds documents. A call to `consolidate` finalizes the index before `search` runs. A negative field weight lowers a document's score when a query term appears in that field.

- Downloads / mo: 277.9K
- Stars: 74
- Last release: 3.1.2
- License: MIT
- Capabilities: [From the wink-bm25-text-search docs](https://raw.githubusercontent.com/winkjs/wink-bm25-text-search/master/README.md)

**Strengths**

- **Field weights can be negative.** Set a weight per field. A negative weight pushes down documents that match in that field.
- **Pluggable text preparation.** Plug in wink-nlp for stemming, stop-word removal, and negation handling.

**Watch out for**

- **Closed after consolidation.** No documents can be added after `consolidate`. The README suggests exporting JSON before consolidating, then importing it to add more.
- **Setup order.** `defineConfig` and `definePrepTasks` must run before any document is added.

```sh
npm install wink-bm25-text-search
```

**Stevenic/vectra** (634 stars)

[Stevenic/vectra](https://github.com/Stevenic/vectra) 

```javascript
public async queryItems<TItemMetadata extends TMetadata = TMetadata>(
    vector: number[],
    query: string,
    topK: number,
    filter?: MetadataFilter,
    isBm25?: boolean
  ): Promise<QueryResult<TItemMetadata>[]> {
    await this.loadIndexData();

    // Filter items
    let items = this._data!.items;
    if (filter) {
      items = items.filter(i => ItemSelector.select(i.metadata, filter));
    }

    // Find top K by cosine similarity using a bounded min-heap of size K.
    // For N items this is O(N log K) vs the previous O(N log N) full sort.
    const norm = ItemSelector.normalize(vector);
    const k = Math.min(topK, items.length);
    const heap: { index: number; distance: number }[] = [];
    const siftUp = (start: number) => {
      let i = start;
      while (i > 0) {
        const parent = (i - 1) >> 1;
        if (heap[parent].distance > heap[i].distance) {
          const tmp = heap[parent]; heap[parent] = heap[i]; heap[i] = tmp;
          i = parent;
        } else break;
      }
    };
    const siftDown = () => {
      let i = 0;
      const n = heap.length;
      while (true) {
        const l = (i << 1) + 1;
        const r = l + 1;
        let smallest = i;
        if (l < n && heap[l].distance < heap[smallest].distance) smallest = l;
        if (r < n && heap[r].distance < heap[smallest].distance) smallest = r;
        if (smallest === i) break;
        const tmp = heap[i]; heap[i] = heap[smallest]; heap[smallest] = tmp;
        i = smallest;
      }
    };
    for (let i = 0; i < items.length; i++) {
      const distance = ItemSelector.normalizedCosineSimilarity(vector, norm, items[i].vector, items[i].norm);
      if (heap.length < k) {
        heap.push({ index: i, distance });
        siftUp(heap.length - 1);
      } else if (k > 0 && distance > heap[0].distance) {
        heap[0] = { index: i, distance };
        siftDown();
      }
    }
    heap.sort((a, b) => b.distance - a.distance);

    // Find top k
    const top: QueryResult<TItemMetadata>[] = heap.map(d => {
      return {
        item: Object.assign({}, items[d.index]) as any,
        score: d.distance
      };
    });

    // Load external metadata in parallel — each file is independent, and the
    // top-K size is small, so this is bounded fan-out.
    await Promise.all(top.map(async (item) => {
      if (item.item.metadataFile) {
        const metadataPath = path.join(this._folderPath, item.item.metadataFile);
        const metadataBuffer = await this.storage.readFile(metadataPath);
        item.item.metadata = this._codec.deserializeMetadata(metadataBuffer) as any;
      }
    }));

    // Perform bm25 search only if enabled. Avoid duplicate chunks that are already selected during semantic search.
    if (isBm25) {
      const itemSet = new Set<string>();
      for (const r of top) itemSet.add(r.item.id);

      // Set up BM25 engine
      await this.setupBm25();

      // Add docs if we have necessary metadata; guard everything to avoid crashes
      for (let i = 0; i < items.length; i++) {
        if (!itemSet.has(items[i].id)) {
          const item = items[i] as any;
          const md = item.metadata || {};
          if (md.documentId != undefined && md.startPos != undefined && md.endPos != undefined) {
            try {
              const currDocTxt = await this._docReader(String(md.documentId));
              const startPos = Number(md.startPos);
              const endPos = Number(md.endPos);
              const chunkText = currDocTxt.substring(startPos, endPos + 1);
              this._bm25Engine.addDoc?.({ body: chunkText }, i);
            } catch {
              // Ignore load or engine errors for BM25 doc prep
            }
          }
        }
      }

      this._bm25Engine.consolidate?.();

      const results: any[] = await this.bm25Search(query, items, topK);

      results.forEach((res: any) => {
        // Support both [index, score] tuples and { item, score } objects
        if (Array.isArray(res)) {
          const idx = res[0];
          const score = res[1];
          if (items[idx]) {
            top.push({
              item: Object.assign({}, { ...items[idx], metadata: { ...items[idx].metadata, isBm25: true } }) as any,
              score
            });
          }
        } else if (res && typeof res === 'object' && 'item' in res && 'score' in res) {
          const objItem = Object.assign({}, { ...(res.item || {}), metadata: { ...(res.item?.metadata || {}), isBm25: true } }) as any;
          top.push({ item: objItem, score: res.score });
        }
      });
    }

    return top;
  }

```

[src/LocalIndex.ts](https://github.com/Stevenic/vectra/blob/dec2dadc3bb158b06ac72fa9097bee729429a271/src/LocalIndex.ts#L338-L462) · [More projects using wink-bm25-text-search →](https://dashboard.exa.ai/playground/search?q=wink-bm25-text-search%20GitHub%20projects)

**Quickstart**

```javascript
var bm25 = require( 'wink-bm25-text-search' );
var engine = bm25();
var docs = require( 'wink-bm25-text-search/sample-data/demo-data-for-wink-bm25.json' );
const winkNLP = require( 'wink-nlp' );
const model = require( 'wink-eng-lite-web-model' );
const nlp = winkNLP( model );
const its = nlp.its;
const prepTask = function ( text ) {
  const tokens = [];
  nlp.readDoc(text)
      .tokens()
      .filter( (t) => ( t.out(its.type) === 'word' && !t.out(its.stopWordFlag) ) )
      .each( (t) => tokens.push( (t.out(its.negationFlag)) ? '!' + t.out(its.stem) : t.out(its.stem) ) );
  return tokens;
};
var query;
engine.defineConfig( { fldWeights: { title: 1, body: 2 } } );
engine.definePrepTasks( [ prepTask ] );
docs.forEach( function ( doc, i ) {
  engine.addDoc( doc, i );
} );
engine.consolidate();
query = 'not studied law';
var results = engine.search( query );

```

From [README.md](https://raw.githubusercontent.com/winkjs/wink-bm25-text-search/master/README.md)

## FAQ

### Which JavaScript search library should I use?

Use [MiniSearch](#minisearch) to search app documents, especially ones users add or edit. Use [Fuse.js](#fuse-js) for typo-tolerant matching over a short list, and [Lunr](#lunr) for a static site whose index is built ahead of time. Choose [Orama](#orama) when an app also needs vector search.

### What is MiniSearch?

MiniSearch is a full-text search engine that keeps its index in memory, in the browser or in Node.js. It supports prefix search, fuzzy search, and field boosts, and documents can be added or removed at any time.

### What is FlexSearch?

FlexSearch is a full-text search library, tuned through its tokenizer and scalable with worker threads. Its persistent indexes keep the index in IndexedDB, Redis, SQLite, or another database instead of memory.

### How do I add fuzzy search in JavaScript?

Use [Fuse.js](#fuse-js) to fuzzy-match a short list of names or labels. For larger document sets, turn on the fuzzy option in [MiniSearch](#minisearch), which scales the allowed edit distance with the length of each term.

### What is Orama search?

Orama is a search engine written in TypeScript that runs full-text, vector, and hybrid search over a custom schema. It works in the browser, on a server, or at the edge.

### Is Lunr.js still a good choice?

Yes, for static sites: build the index at deploy time and load it in the browser. A Lunr index can't change after it's built, and the last release was in Aug 2020, so use [MiniSearch](#minisearch) when documents change while the app runs.

## How this page was built

Data checked Nov 18, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript search libraries Fuse.js MiniSearch FlexSearch Lunr full text fuzzy search code examples Orama",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
