fuse.js vs lunr vs flexsearch vs elasticlunr vs search-index
JavaScript Search Libraries
fuse.jslunrflexsearchelasticlunrsearch-indexSimilar Packages:
JavaScript Search Libraries

JavaScript search libraries provide tools for implementing search functionality within web applications. These libraries can index data, perform searches, and return results based on user queries. They vary in features, performance, and complexity, catering to different use cases such as simple text search, full-text search, and search with advanced features like ranking, highlighting, and fuzzy matching. Choosing the right search library depends on factors like the size of the dataset, the complexity of search queries, and the need for features like real-time indexing or multi-language support.

Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
fuse.js5,587,65519,720456 kB1110 months agoApache-2.0
lunr4,006,1809,170-1305 years agoMIT
flexsearch495,38113,4512.33 MB222 months agoApache-2.0
elasticlunr27,7902,079-779 years agoMIT
search-index20,2711,420693 kB58 months agoMIT
Feature Comparison: fuse.js vs lunr vs flexsearch vs elasticlunr vs search-index

Indexing Method

  • fuse.js:

    fuse.js does not create a traditional index. Instead, it builds a lightweight, in-memory structure that supports fuzzy searching. This approach is simple and effective for small to medium datasets but may not scale well for larger datasets.

  • lunr:

    lunr builds a compact inverted index that is stored in memory. It supports multi-field indexing, custom tokenization, and provides a simple API for searching. The index is created once and used for fast search queries.

  • flexsearch:

    flexsearch offers multiple indexing strategies, including traditional inverted indexing and a more memory-efficient approach. It supports real-time indexing and allows for fine-tuning of the indexing process, making it highly versatile.

  • elasticlunr:

    elasticlunr creates an inverted index in memory, allowing for efficient search operations. It supports custom tokenization and stemming, making it flexible for different types of text data.

  • search-index:

    search-index creates a full-text index using inverted indexing. It supports real-time indexing, multi-field indexing, and allows for complex queries. The indexing process is highly configurable, making it suitable for dynamic datasets.

Fuzzy Search Support

  • fuse.js:

    fuse.js is known for its fuzzy search capabilities, allowing for approximate matching of strings. It provides configurable fuzziness, making it easy to adjust the sensitivity of the search.

  • lunr:

    lunr does not natively support fuzzy searching. However, it can be extended with plugins to add this feature. By default, it focuses on exact and partial matches.

  • flexsearch:

    flexsearch provides advanced fuzzy search capabilities with configurable algorithms. It allows for fine-tuning the fuzziness level, making it one of the most feature-rich libraries for fuzzy searching.

  • elasticlunr:

    elasticlunr supports basic fuzzy searching through configurable edit distance. It allows for approximate matching, but the implementation is relatively simple compared to more advanced libraries.

  • search-index:

    search-index supports fuzzy searching as part of its full-text search capabilities. It allows for configurable fuzziness, making it suitable for applications that require approximate matching.

Real-time Indexing

  • fuse.js:

    fuse.js does not support real-time indexing as it requires the dataset to be loaded into memory before searching. However, the dataset can be updated dynamically, and the search will reflect the changes immediately.

  • lunr:

    lunr does not support real-time indexing. The index is built once and cannot be updated without rebuilding it. This makes it more suitable for static datasets.

  • flexsearch:

    flexsearch supports real-time indexing, allowing for updates to the index without needing to rebuild it. This feature makes it suitable for dynamic applications where data changes frequently.

  • elasticlunr:

    elasticlunr does not support real-time indexing out of the box. Indexing is done manually, and the library is designed for static or semi-static datasets.

  • search-index:

    search-index supports real-time indexing, allowing for continuous updates to the index as new data is added. This feature is ideal for applications with frequently changing data.

Memory Usage

  • fuse.js:

    fuse.js has a low memory footprint, making it suitable for small to medium datasets. However, memory usage can increase significantly with larger datasets due to its in-memory search structure.

  • lunr:

    lunr is relatively memory-efficient for the features it provides. However, memory usage grows with the size of the dataset, particularly during indexing.

  • flexsearch:

    flexsearch is designed to be memory-efficient, especially with its configurable indexing options. It uses advanced algorithms to minimize memory usage while providing fast search performance.

  • elasticlunr:

    elasticlunr is lightweight and has a low memory footprint, making it suitable for client-side applications. However, memory usage increases with the size of the dataset due to the in-memory index.

  • search-index:

    search-index can be memory-intensive, especially with large datasets, due to its full-text indexing approach. However, it provides options for optimizing memory usage during indexing and searching.

Ease of Use: Code Examples

  • fuse.js:

    Simple Fuzzy Search with fuse.js

    const Fuse = require('fuse.js');
    const data = [
      { id: 1, title: 'Hello World', body: 'This is a test document.' },
      { id: 2, title: 'Elastic Search', body: 'Searching with fuse.js.' },
    ];
    
    const fuse = new Fuse(data, { keys: ['title', 'body'], threshold: 0.3 });
    const results = fuse.search('test');
    console.log(results);
    
  • lunr:

    Simple Search with lunr

    const lunr = require('lunr');
    const index = lunr(function () {
      this.ref('id');
      this.field('title');
      this.field('body');
    });
    
    index.add({ id: 1, title: 'Hello World', body: 'This is a test document.' });
    index.add({ id: 2, title: 'Elastic Search', body: 'Searching with lunr.js.' });
    
    const results = index.search('test');
    console.log(results);
    
  • flexsearch:

    Simple Search with flexsearch

    const FlexSearch = require('flexsearch');
    const index = new FlexSearch.Index();
    
    index.add(1, { title: 'Hello World', body: 'This is a test document.' });
    index.add(2, { title: 'Elastic Search', body: 'Searching with flexsearch.' });
    
    index.search('test').then(results => {
      console.log(results);
    });
    
  • elasticlunr:

    Simple Search with elasticlunr

    const elasticlunr = require('elasticlunr');
    const index = elasticlunr(function () {
      this.addField('title');
      this.addField('body');
      this.setRef('id');
    });
    
    index.addDoc({ id: 1, title: 'Hello World', body: 'This is a test document.' });
    index.addDoc({ id: 2, title: 'Elastic Search', body: 'Searching with elasticlunr.js.' });
    
    const results = index.search('test');
    console.log(results);
    
  • search-index:

    Simple Search with search-index

    const si = require('search-index');
    const index = si({ name: 'my-index' });
    
    index({ id: 1, title: 'Hello World', body: 'This is a test document.' });
    index({ id: 2, title: 'Elastic Search', body: 'Searching with search-index.' });
    
    index.search('test').then(results => {
      console.log(results);
    });
    
How to Choose: fuse.js vs lunr vs flexsearch vs elasticlunr vs search-index
  • fuse.js:

    Choose fuse.js if you need a simple, lightweight library for fuzzy searching within a dataset. It works well for small to medium-sized datasets and allows for easy configuration of search algorithms, making it ideal for applications that require approximate matching.

  • lunr:

    Choose lunr if you want a simple, self-contained full-text search library that creates an index in the browser. It is suitable for static sites or applications with a fixed dataset, providing fast search capabilities without the need for a server.

  • flexsearch:

    Choose flexsearch if you require a high-performance, feature-rich search library with support for fuzzy searching, multi-language indexing, and real-time updates. It is suitable for applications that need fast search capabilities with minimal memory usage.

  • elasticlunr:

    Choose elasticlunr if you need a lightweight, client-side search library that mimics Elasticsearch's API. It's great for small to medium datasets and offers features like stemming, tokenization, and custom scoring.

  • search-index:

    Choose search-index if you need a full-featured, Node.js-based search indexing solution that supports real-time indexing, multi-field search, and advanced features like faceting and ranking. It is ideal for applications that require more control over the indexing and search process.

README for fuse.js

Fuse.js

Node.js CI Version Downloads code style: prettier Contributors License

Supporting Fuse.js

Through contributions, donations, and sponsorship, you allow Fuse.js to thrive. Also, you will be recognized as a beacon of support to open-source developers.


Sponsors


Introduction

Fuse.js is a lightweight fuzzy-search, in JavaScript, with zero dependencies.

Browser Compatibility

Fuse.js supports all browsers that are ES5-compliant (IE8 and below are not supported).

Documentation

To check out a live demo and docs, visit fusejs.io.

Develop

Here's a separate document for developers.

Contribute

We've set up a separate document for our contribution guidelines.