Techniques for full-text searching within PourOver?
nicksergeant opened this issue · 3 comments
Hi there! Love the library. It's almost like you were reading my mind. I run http://broker.is/ and you solved/are attempting to solve my two biggest pain points. I'll be using PourOver/Tamper exclusively for this project, so I'll focus on bringing functionality over here when appropriate :)
Anyways, my original question is this: do you have any ideas / suggestions for full-text filtering within a PourOver collection? PourOver is excellent for categorical filtering, sorting, and pagination, but I also have a full-text querying component to my collections. If I want to use the built-in pagination / sorting with PourOver, I'd need to devise a way to integrate full-text searching on specific fields in PourOver, instead of doing that after the collection has been filtered via PO.
My idea was to do this is as a manual filter. Does that sound like an appropriate approach, or do you have any ideas on how else to handle this type of a situation?
Glad to hear you are liking it! Absolutely, a good way would be to use manualFilter. Basically on every search use something like (http://kiro.me/projects/fuse.html) to search. Then return the cids, update a manualFilter with them and, boom, problem solved. You'd still be able to compose this filter with other, categorical filters if you wanted to.
Perfect, makes sense. And thanks for the link to Fuse, hadn't seen that before!
I took a crack at implementing text search on headlines using Bloodhound because ¯\_(ツ)_/¯
. The only tricky part is negating the manualFilter. If you pass an empty array to your manualFilter — named title
here — like so collection.filter.title.query([])
the manualFilter does what it wants to do, I imagine, which is return zero results because it has offers no cids to match against.
To get around this, I stored a list of cids on load and if my input field has no text value, I skip Bloodhound and set the manualFilter to include all cids. Not sure if there's a better way but this works for now.
jsFiddle
Tip: Searching for jedi
or ewok
will give you keywords that overlap / are unique to certain entries.