Love the library so far, great work! One potential enhancement, (which if I find time I would love to do myself). Sometimes you want certain keys to have a stronger weighting. For example if you were searching for "Cheese" through the following library of books, you would maybe want "French Cheeses" to be your top match, however at the moment "101 Sandwiches" would take top billing due to a higher score in the description field.
[{
"title": "French cheeses",
"description": "Pictures and descriptions of all the cheeses France has to offer"
}, {
"title": "101 Sandwiches",
"description": "Cheese, Ham, Pickle sandwich all the things"
}]
What I propose is an optional more advanced syntax for keys, where you provide some kind of modifier to that key making it less/more important than it's siblings. The final scoring could then be skewed via it's modifier.
keys = [{
label: 'title',
modifier: 1,
}, {
label: 'description',
modifier: 0.5,
}]
I like this.
Thanks for a great suggestion. Let's make it happen :+1:
Implementation:
var fuse = new Fuse(books, {
keys: [{
name: 'title',
weight: 0.3
}, {
name: 'author',
weight: 0.7
}],
});
Where 0 < weight <= 1
I published a new version: 2.1.0-beta. Let me know what you think.
Thanks!
@krisk in your example, is title or author more heavily weighted?
Most helpful comment
Implementation:
Where
0 < weight <= 1I published a new version: 2.1.0-beta. Let me know what you think.
Thanks!