Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search across multiple item properties #86

Open
caschbre opened this issue Oct 20, 2021 · 4 comments
Open

Search across multiple item properties #86

caschbre opened this issue Oct 20, 2021 · 4 comments
Labels
enhancement New feature or request help wanted Maintainers need help from contributors

Comments

@caschbre
Copy link

Is your feature request related to a problem? Please describe.
I've been looking for a replacement to fuse.js and came across this library. I use fzf all over my OS and like the speed and results it produces. This nearly replaces all of the features I currently use on fuse.js except for one key aspect. The ability to have weighted search across multiple item properties. You can see a fusejs example here. I think right now my only option is to use the non-string selector feature by concatenating the properties. That can get messy though if all of the properties are not simple terms/words... and I'm not sure how that would affect scoring.

An example usage could be searching calendar events that include an event title, name of the host, names of all the participants, and a short description.

{
  title: 'Learn how to fzf!',
  host: 'Ajit',
  participants: ['Craig', 'John', 'Bill'],
  description: 'How to use fzf on your OS, in vim, and now in JS!',
}

Describe the solution you'd like
A possible solution without weighting the item properties might be to search and score each searchable property. And then calculate a single score for the item. Some simple (configurable) item scoring calculates could be total score, average score, or highest score. And then if anyone wanted to hook into the scoring algorithm they could implement a weighted scoring algo.

Describe alternatives you've considered
After searching for fusejs alternatives, fzf is the one I chose to dive into first so I haven't looked hard at other fuzzy search/sort libraries. And the only alternative within fzf that I've found is the concatenating properties in the selector.

@caschbre caschbre added the enhancement New feature or request label Oct 20, 2021
@ajitid
Copy link
Owner

ajitid commented Oct 20, 2021

I haven't looked hard at other fuzzy search/sort libraries.

If your requirement is immediate, I would suggest you to look into match-sorter and fuzzysort.

This is certainly one of the things I have in my mind to work upon. Honestly, I haven't had a chance to look into how others have implemented it, probably now is the time. 😅

@ajitid
Copy link
Owner

ajitid commented Oct 31, 2021

Hey @caschbre! It seems that in both match-sorter and fuzzysort one cannot search in multiple fields at once. So in the example that you've given above, searching for "how to fzf ajit" won't give any result. Does this matches to the result that you are expecting?

@caschbre
Copy link
Author

caschbre commented Nov 1, 2021

@ajitid I have not had a chance to try either one out yet. We're currently using fusejs which handles multiple fields, but I've been looking for something that performs better (speed and accuracy) and is easier to customize.

I briefly looked over the two libraries you mentioned and I believe that match-sorter does search across multiple fields by configuring the 'keys'. Also see https://github.com/kentcdodds/match-sorter#match-many-words-across-multiple-fields-table-filtering.

@ajitid ajitid added the help wanted Maintainers need help from contributors label Feb 27, 2022
@ajitid
Copy link
Owner

ajitid commented Mar 21, 2023

For others stumbling upon this issue, I'm not planning to work on this. I did clone the approach that match-sorter does (which @/caschbre mentioned just above), but that didn't feel right.

However I'll happily accept a PR which solves this properly. I've already put a 'help-wanted' label an year ago. Am I'm commenting now just to clarify it. If you think you can help but have questions on parts of the code, create a new issue and put those questions there, and I'll reply back to you. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Maintainers need help from contributors
Projects
None yet
Development

No branches or pull requests

2 participants