krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
17.89k stars 759 forks source link

Getting wrong results, is it possible two combine search keys? #499

Closed karahan closed 3 years ago

karahan commented 3 years ago

These are my settings.

shouldSort: true,
threshold: 0.8,
keys: ['make', 'model']

and this is the searched array

[
    { make: "Audi", model: "A5" },
    { make: "Audi", model: "A6 avant" },
]

If I search "Audi A5" the audi a6 avant shows up first. I think it has to do with the fact that the whole "Audi A5" string is being matched with both the Make and Model

karahan commented 3 years ago

Is it possible to combine the keys in the search so it searches both Make and Model together like a concatenated string?

karahan commented 3 years ago

So far i've tried mapping the make + model in one string and using that new key as the searchkey as option (this works good). But i was wondering if there is any functionality like this built-in and im just missing it

krisk commented 3 years ago

Yes, there is a way. You can use the logical query operator $AND.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days