Closed dannydan412 closed 7 years ago
@dannydan412 , what is the status of this integration?
This could be great.
@dannydan412 @olivernn This feature would really complete this package. I could really make use of it. Was any work done towards this end?
+1
After tinkering with lunr trying to get it to fuzzy search by itself I stumbled upon this issue.
A quick hack gave me this:
var lunr = require('lunr');
var FuzzySet = require('fuzzyset.js');
var FUZZY_MATCH = 0.1;
var index = lunr(function () {
this.field('title', { boost: 5 });
this.field('path');
this.ref('id');
var titles = models.map(function (m) { return m.title; });
var fuzzy = FuzzySet(titles);
this.pipeline.add(function (token) {
var matches = fuzzy.get(token);
if (matches && matches[0][0] >= FUZZY_MATCH) return matches[0][1];
else return token;
});
});
The models in my example are simply objects where we're only interested in doing fuzzy search on their titles.
Integrating on application level is easy enough for simple cases at least :)
The latest version of Lunr does not support fuzzy matching when performing searches.
Correction to the above comment: Lunr does support fuzzy matching.
Hey Oliver,
I was thinking of combining lunr with fuzzyset.js to allow for fuzzy searching. The idea is to modify the token store and replace the expand() method so that it uses the fuzzy matching results. The only problem is "similarityBoost" doesn't seem to provide sufficient penalty on matches that have a low fuzzy matching score (also between 0 and 1). Would you have any ideas on how to improve this?