FuzzySearch options
See original GitHub issueI had problems with sending options to FuzzySearch. If you look at the fuzzy search page, it says:
var fuzzyOptions = { searchClass: “fuzzy-search”, location: 0, distance: 100, threshold: 0.4, multiSearch: true }; var options = { valueNames: [ ‘name’, ‘category’ ], plugins: [ ListFuzzySearch() ] };
var listObj = new List(‘list-id’, options);
As far as I can see, the fuzzy options are never sent to the fuzzy search plugin, and so the default is always used regardless of what values you put in the fuzzyOptions. There is also no info about where to send in the options, but after a bit of debugging I found that I could send it in to the constructor: ListFuzzySearch(fuzzyOptions)
Then on to the next problem. Once I sent in the options, nothing changed. Seems that the “module.exports = function extend (object)”-function just overwrote the options I sent in with the default options. So I had to change from
for (var i = 0, source; source = args[i]; i++) {
if (!source) continue;
for (var property in source) {
object[property] = source[property];
}
}
to
for (var i = 0, source; source = args[i]; i++) {
if (!source) continue;
for (var property in source) {
if (typeof object[property] == 'undefined') {
object[property] = source[property];
}
}
}
to protect my options from being overwritten
And by the way, setting threshold: 0.0 doesn’t disable fuzzy search like it says in the documentation. Instead it switches to the default value of 0.4 in this line: var Match_Threshold = options.threshold || 0.4;
But a value of 0.000001 almooost disables it 😃
Issue Analytics
- State:
- Created 9 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
I noticed this today too. Is this abandonware? How come there is no new release or simple fix to this a year later?
+1 to get this fixed
There is a bug in the fuzzy search options that will be fixed in the next version.