krisk / Fuse

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

Searching within the last search's results instead of the whole data set. #514

Closed mikeyhunt closed 3 years ago

mikeyhunt commented 3 years ago

Is there any chance to force fuse to search within a past search instead of the whole data set? I have a screen like this:

https://i.imgur.com/TL9VwoX.png

You can see the categories are on top, the tags on the bottom. The category is more important than the tag, so, it should be the driver of the filtering. When the user clicks a tag, the system filters the list as is - but when the user clicks a category, any tag already selected or selected afterwards will have to search within the constraints of that category.

My items' data set is exactly this:

categories: [
  {
    handle: 'restaurant',
    niceName: 'Restaurant'
  }
],

tags: [ 'food', 'eating']

And the fuse setup:

    const fuse = new Fuse(entities, {
        keys: [
            {
                name: 'categories.handle',
                weight: 10
            },
            'tags'
        ]
    });

The tool doesn't work exactly as it should because it's still searching on the whole data-set. Is there no way to force it to always perform a search on a category first (if it's selected) then search on the tag?


Thanks a metric ton for the tool, it's god-sent and once Patreon decides to stop messing with my PP, I'll start supporting. A really, really great tool.

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