fuse.js vs fuzzysort vs fuzzy-search vs fuzzysearch vs elasticlunr
JavaScript Fuzzy Search and Indexing Libraries Comparison
1 Year
fuse.jsfuzzysortfuzzy-searchfuzzysearchelasticlunrSimilar Packages:
What's JavaScript Fuzzy Search and Indexing Libraries?

Fuzzy search and indexing libraries in JavaScript provide tools for searching and retrieving data with approximate matching, allowing for errors, typos, or variations in the search terms. These libraries are useful for implementing search functionality that is more forgiving and user-friendly, especially when dealing with large datasets or when the input may not be perfectly accurate. They use algorithms that calculate the similarity between strings and return results based on a defined threshold, making them ideal for applications like search engines, autocomplete features, and data retrieval systems. elasticlunr is a lightweight, full-text search library that creates an inverted index for fast searching, supporting stemming, tokenization, and custom analyzers. fuse.js is a powerful, lightweight fuzzy-search library that performs client-side searches with high accuracy, allowing for configurable matching algorithms, scoring, and support for nested objects. fuzzy-search is a simple and efficient library for performing fuzzy searches on arrays of strings or objects, offering a straightforward API and customizable matching logic. fuzzysearch is a tiny, fast utility for checking if a substring exists within a string with fuzzy matching, ideal for quick and lightweight searches without the overhead of complex algorithms. fuzzysort is a high-performance fuzzy sorting library that ranks results based on their similarity to the search term, providing fast and accurate matches with a focus on sorting rather than just searching.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
fuse.js3,924,16719,002456 kB142 months agoApache-2.0
fuzzysort401,5744,08845.6 kB96 months agoMIT
fuzzy-search160,225226-165 years agoISC
fuzzysearch107,7312,724-510 years agoMIT
elasticlunr27,5262,059-779 years agoMIT
Feature Comparison: fuse.js vs fuzzysort vs fuzzy-search vs fuzzysearch vs elasticlunr

Search Algorithm

  • fuse.js:

    fuse.js employs a fuzzy matching algorithm that calculates the similarity between the search term and the target strings. It allows for configurable thresholds, weights, and scoring, making it highly flexible and accurate for searching within complex data structures.

  • fuzzysort:

    fuzzysort utilizes a high-performance fuzzy matching algorithm that ranks results based on their similarity to the search term. It focuses on sorting the matches by their fuzziness score, providing a fast and accurate way to retrieve and display results.

  • fuzzy-search:

    fuzzy-search implements a simple fuzzy matching algorithm that compares the search term with the target strings or object properties. It provides a straightforward approach to finding matches with a customizable level of fuzziness, making it efficient for quick searches.

  • fuzzysearch:

    fuzzysearch uses a fast substring search algorithm that allows for approximate matching of a substring within a string. It is designed for quick lookups and is particularly efficient for checking the presence of fuzzy matches without extensive processing.

  • elasticlunr:

    elasticlunr uses an inverted index for full-text search, allowing for fast retrieval of documents based on indexed terms. It supports stemming and tokenization, which helps in matching terms more effectively, even if they are not an exact match.

Data Structure Support

  • fuse.js:

    fuse.js is designed to work with various data structures, including arrays of strings, objects, and nested data. It provides flexible options for specifying which fields to search, making it suitable for complex and hierarchical data.

  • fuzzysort:

    fuzzysort is compatible with arrays of strings and objects, providing fuzzy matching and sorting capabilities. It can handle both simple and structured data, making it versatile for various applications.

  • fuzzy-search:

    fuzzy-search works with arrays of strings and objects, allowing for fuzzy matching on both simple and complex data. It supports searching through object properties, making it adaptable to different data formats.

  • fuzzysearch:

    fuzzysearch operates on strings, making it ideal for searching within text data. It is focused on substring matching and does not support complex data structures, which keeps it simple and efficient.

  • elasticlunr:

    elasticlunr supports indexing and searching through plain text, as well as structured data like objects and arrays. It allows for custom tokenization and analysis, making it versatile for different types of data.

Customization

  • fuse.js:

    fuse.js offers extensive customization options for the search algorithm, including the ability to adjust the fuzziness level, weight different fields, and define custom matching functions. This makes it highly adaptable to different use cases and data types.

  • fuzzysort:

    fuzzysort allows for some customization of the matching and sorting process, including the ability to adjust the fuzziness threshold and define custom scoring functions. It is designed to be fast and efficient while still providing flexibility for developers.

  • fuzzy-search:

    fuzzy-search provides basic customization features, such as adjusting the fuzziness level and specifying which properties to search in objects. However, it is more limited compared to other libraries, focusing on simplicity and ease of use.

  • fuzzysearch:

    fuzzysearch is minimalistic and does not offer much customization beyond adjusting the fuzziness of the substring search. Its simplicity is its strength, making it easy to use without complex configuration.

  • elasticlunr:

    elasticlunr allows for customization of the indexing and searching process, including the ability to define custom tokenizers, analyzers, and scoring algorithms. This flexibility enables developers to tailor the search functionality to meet specific requirements.

Performance

  • fuse.js:

    fuse.js is performant for client-side searches, but its speed can vary depending on the size of the dataset and the complexity of the search configuration. It is best used with optimized data and reasonable fuzziness settings to maintain good performance.

  • fuzzysort:

    fuzzysort is known for its high performance, particularly in ranking and sorting fuzzy matches. It is optimized for speed, making it a great choice for applications that need quick search results with minimal latency.

  • fuzzy-search:

    fuzzy-search is designed for efficiency, providing fast fuzzy search capabilities on arrays. Its performance is generally good, making it suitable for applications that require quick lookups without significant overhead.

  • fuzzysearch:

    fuzzysearch is extremely fast, especially for checking the presence of a substring within a string. Its lightweight nature and simple algorithm make it ideal for performance-critical applications where speed is essential.

  • elasticlunr:

    elasticlunr is optimized for fast search performance, especially after the initial indexing phase. The use of an inverted index allows for quick lookups, making it suitable for real-time search applications with moderate-sized datasets.

Ease of Use: Code Examples

  • fuse.js:

    Basic Usage of fuse.js

    // Import the library
    const Fuse = require('fuse.js');
    
    // Sample data
    const data = [
      { id: 1, title: 'Apple', tags: ['fruit', 'food'] },
      { id: 2, title: 'Banana', tags: ['fruit', 'yellow'] },
      { id: 3, title: 'Carrot', tags: ['vegetable', 'orange'] },
    ];
    
    // Configure Fuse.js
    const options = {
      keys: ['title', 'tags'], // Fields to search
      threshold: 0.3, // Fuzziness threshold
    };
    
    // Create a Fuse instance
    const fuse = new Fuse(data, options);
    
    // Perform a search
    const result = fuse.search('app');
    console.log(result);
    
  • fuzzysort:

    Basic Usage of fuzzysort

    // Import the library
    const fuzzysort = require('fuzzysort');
    
    // Sample data
    const items = ['apple', 'banana', 'cherry', 'date'];
    
    // Perform a fuzzy sort
    const results = fuzzysort.go('ap', items);
    console.log(results);
    
  • fuzzy-search:

    Basic Usage of fuzzy-search

    // Import the library
    const { fuzzySearch } = require('fuzzy-search');
    
    // Sample data
    const items = ['apple', 'banana', 'cherry', 'date'];
    
    // Perform a fuzzy search
    const results = fuzzySearch(items, 'appl');
    console.log(results); // Output: ['apple']
    
  • fuzzysearch:

    Basic Usage of fuzzysearch

    // Import the library
    const fuzzysearch = require('fuzzysearch');
    
    // Sample strings
    const str = 'hello world';
    const pattern = 'hlo wr';
    
    // Perform a fuzzy search
    const isMatch = fuzzysearch(pattern, str);
    console.log(isMatch); // Output: true
    
  • elasticlunr:

    Basic Usage of elasticlunr

    // Import the library
    const elasticlunr = require('elasticlunr');
    
    // Create an index
    const index = elasticlunr(function () {
      this.addField('title');
      this.addField('body');
      this.setRef('id');
    });
    
    // Add documents to the index
    index.addDoc({ id: 1, title: 'Hello World', body: 'This is a test document.' });
    index.addDoc({ id: 2, title: 'Elastic Search', body: 'Searching with elasticlunr is fun!' });
    
    // Search the index
    const results = index.search('elastic', { expand: true });
    console.log(results);
    
How to Choose: fuse.js vs fuzzysort vs fuzzy-search vs fuzzysearch vs elasticlunr
  • fuse.js:

    Select fuse.js if you require a highly configurable fuzzy search library that can handle complex data structures, provide detailed matching scores, and allow for customization of the search algorithm. It is suitable for applications where accuracy and flexibility in searching are paramount.

  • fuzzysort:

    Choose fuzzysort if you need a fast fuzzy search library that ranks results based on their similarity to the search term, with a focus on performance and accuracy. It is ideal for applications that require quick searches with sorted results.

  • fuzzy-search:

    Opt for fuzzy-search if you want a simple and efficient solution for performing fuzzy searches on arrays with minimal setup. It is great for projects that need a straightforward implementation without the need for extensive configuration or features.

  • fuzzysearch:

    Use fuzzysearch when you need a lightweight and fast utility for checking the presence of a substring within a string with fuzzy matching. It is perfect for scenarios where performance is critical and you need a no-frills solution.

  • elasticlunr:

    Choose elasticlunr if you need a lightweight, client-side search solution that supports full-text indexing and searching with features like stemming and custom analyzers. It is ideal for applications that require fast search capabilities without the need for a server-side solution.

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.