thisbeyond / solid-select

The Select component for Solid.
https://solid-select.com
MIT License
172 stars 18 forks source link

Fuzzy sort on more than one key #41

Closed xypnox closed 2 months ago

xypnox commented 1 year ago

In the usual scenarios, having a single key to sort the list of data is fine, however, it might be useful to have an array of keys that can be used to match for the fuzzy finder and the higher match score will be used.

martinpengellyphillips commented 1 year ago

Do you have a specific use case in mind? I try to keep solid select opinionated but extensible so cautious in adding more "builtin". Would be good to see an example to play with.

xypnox commented 1 year ago

A few cases come to my mind,

  1. The initial use case that I had was matching a nested set of links by either their entire path or by their name. a.b.c matches with abc and c
  2. Matching name / description of a object
  3. Matching category/name of a object

Sorry for the late reply.

martinpengellyphillips commented 1 year ago

I think it would be useful, but rather than increase the core size of this library I would recommend in your case to integrate a dedicated fuzzy search/sort library. So maybe this is more about providing a more composable way to add own search sort function to the createOptions helpers 🤔

martinpengellyphillips commented 2 months ago

Release 0.15.0 has now been published which makes this easier, though does not yet build in a multi-field fuzzySort. However, you can check out the new example on the website that shows one approach to do this: https://solid-select.com/?example=Filterable%2520%28Custom%29