Class

FuzzySearch

FuzzySearch()

Constructor

# new FuzzySearch()

fuzzy-search.jsxinc.
by Duduf and Wouter Rutgers.
Version:
  • 1.0.0
Author:
  • Nicolas Dufresne and contributors
License:
  • GNU-GPLv3

View Source DuESF.jsxinc, line 5823

Example
// Encapsulate everything to avoid global variables!
(function() {
    #include "fuzzy-search.jsxinc"

    var people = [{
    name: {
        firstName: 'Jesse',
        lastName: 'Bowen',
    },
   state: 'Seattle',
    }];

    var searcher = new FuzzySearch(people, ['name.firstName', 'state'], {
        caseSensitive: true,
    });
    var result = searcher.search('ess');
})();

Methods

# static match(item, query, caseSensitiveopt) → {float}

Caculates the score of a string against a query
Parameters:
Name Type Attributes Default Description
item string The string to test
query string The string to search
caseSensitive bool <optional>
false Whether to check the case or not

View Source DuESF.jsxinc, line 5917

The score, a positive value.
- 0: no match
- 1: perfect match
- >1: the lower the score, the better the match
float
Searches for items in the haystack
Parameters:
Name Type Description
query string The string to search

View Source DuESF.jsxinc, line 5847

The matching results. Objects with two attributes: item and score.
Array.<Obbject>