typeahead.js
typeahead.js copied to clipboard
Allow the search index class to be provided by the user in `index`.
Defaults to SearchIndex otherwise.
Could be a very simple fix for #96.
(If this kind of change is desirable I'll be more than happy to supplement it with documentation updates.)
Out of curiosity, are you overriding the search index?
Yes, and in case you wonder why:
The default SearchIndex (and Trie) work great if you autocomplete strings and it always makes sense to really complete them - as in, the user starts typing, and typeahead.js suggests completions. But I use typeahead.js to autocomplete what area really richer objects that are managed elsewhere in my app, and the constraints (dataset size, frequency of updates) and requirements (autocomplete based on fragments that can be located anywhere, multiple data types) make the plugin not very flexible.
By overriding the search index, I can control everything from storage to retrieval, and it just works great. (I did have to add a couple of right-to-left nits to support bidirectional layouts but that's unrelated to this pull request.) One use-case with code is in the linked issue #96.
Since it's a one line change, and drawing the line in the sand at the search index class (rather than the Trie) makes a lot of sense to me, I figured this might be a good candidate for a pull request.
:+1:
it would be good to get this merged in, or at least looked at. from a docs perspective, bloodhound is touted as an awesome advanced suggestion library... but right now it's handicapped by only being able to do very basic matching.
This is a fairly big issue and a very plausible use case has been suggested (https://github.com/twitter/typeahead.js/issues/96#issuecomment-21574931)
I was actually going to do something like this. In fact it can solve sooo many problems such fuzzy search (https://github.com/twitter/typeahead.js/issues/525) which in fact I did using a library called Fuse.js. I would make a pull request, but currently this repository has been inactive for quite some while!
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
eladxxx seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.
Whoop! 5 years and counting!