brianreavis / sifter.js

A library for textually searching arrays and hashes of objects by property (or multiple properties). Designed specifically for autocomplete.
1.1k stars 125 forks source link

possibility to match only items, that **starts with** #15

Open hidegh opened 9 years ago

hidegh commented 9 years ago

this function is especially important if searching only by a single column. creating own score function is not a good solution, thus it has to handle separately diacritics. need this function to have inside selectize.js

hidegh commented 9 years ago

since similar functionality can be achieved inside the scoring function, the only real job is to create a public function which changes the special diacritics char so invariant search would be possible

brianreavis commented 9 years ago

@hidegh Or: just adjust tokenize to not split on spaces and add a ^ to the beginning of the regexp that it produces.

hidegh commented 9 years ago

@brianreavis Actually I don't understand Sifter in details and would like to avoid any change inside a code that is maintained by other developers (by you) - since any change and component update then would need to be 'updated' locally, just to support my 'special' search - so that is not an option.

To overload just that function is a bit better solution, but again, until I dont know how exactly it works, i'd like to avoid.

Today maybe i'm the only one who asks for such an options for selectize.js (to support starts with or to support any reges), but i'm sure I won't be the last :smile: But even better is the possibility to pass a regex (which can be constructed from the search term) that has to be matched - which would then be automatically passed form selectize to sifter.. Please consider implementing this. Thanx.

Other remarks: As I've seen lot of people do not read documentation (like the one who complained about not every data being loaded - he had more than 1000) - and sometimes even documentation is missing some details: like option group id with value of 0/false is not rendered as option group :smile:

Still I prefer your code over selec2.js - it's nicer, cleaner (at least for me).

jods4 commented 9 years ago

Indeed searching at word boundaries (\b) or at beginning of string (^) is a much needed addition.

Sifter is used internally by Selectize and when you type a in a drop down and pretty much all results show up it's just weird. You would expect to only see items that starts with a.

RudeySH commented 4 years ago

Did #51 resolve this?