alexurquhart / vue-bootstrap-typeahead

An autocomplete/typeahead component for Vue 2 and Bootstrap 4
https://alexurquhart.github.io/vue-bootstrap-typeahead/
MIT License
206 stars 157 forks source link

Fuzzy search #8

Open Owumaro opened 6 years ago

Owumaro commented 6 years ago

This one is tricky...

https://github.com/alexurquhart/vue-bootstrap-typeahead/blob/85ff0bd1fc947f86959813115d0ed4cf34d3b832/src/components/VueBootstrapTypeaheadList.vue#L83

Currently the results from the backend are filtered using a regexp based on the query. It would be nice to be able to make it fuzzy. Here are a few examples from Google Autocomplete :

image

The - is matched with the space char

image

The c is matched with a k

Not sure if this should be included in the default component, or be allowed as an extra (this will probably require a dependency to a js fuzzy search library).

This issue has low priority :smile:

alexurquhart commented 6 years ago

This is a good idea as well, I think before the components gets a 1.0 release it should allow for both custom highlight and custom matching functions.

boamigo commented 6 years ago

I think this is redundant. Because there will always be requirements to provide more and more fuzzy matching rules. Programmers will never be able to satisfy all fuzzy matching needs.

And by the way, you are always free to create a watcher and provide an array of suggestions yourself and it will work. All you need to do is to use your favorite fuzzy search library and adopt it using watcher as specified in the example in the landing page (just scroll down there is an example with a Watcher).