Filter out bleve search results

231 views
Skip to first unread message

Benjamin BALET

unread,
Jan 25, 2017, 8:48:59 AM1/25/17
to bleve
Hi,

I'm experimenting bleve on an inventory project that allows a global search on all stores. But users can view only the items stored in stores they are granted to access.

My initial solution was to iterate on the searchresults / Hits array and to build a new array by appending only the items users can view (Bleve Doc ID is a joined string of Item ID and storage ID).

I was just wondering if there is a way to safely delete some Hits or another solution.

Benjamin

Marty Schoch

unread,
Jan 27, 2017, 3:54:46 PM1/27/17
to bl...@googlegroups.com
In general trying to filter out undesirable search results after the search has been completed is problematic.  It means you give up features like pagination, because you never know how many items to request, since you end up throwing some away.

A better approach is to index this additional data, and add the filters to the users search query.  So, in your example, if you index a field with each item called "store" using the keyword analyzer (because you only want exact matches on it).  Then when a user searches for X, you instead do the following search:

Conjunction combining
  - Users search X
  - Disjunction consisting of one or more TermSearch for store IDs the user should have access to

Let me know if this isn't clear or if you have more questions about this approach.

marty

--
You received this message because you are subscribed to the Google Groups "bleve" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bleve+unsubscribe@googlegroups.com.
To post to this group, send email to bl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bleve/bc30f961-35fe-4afd-99d9-594004e4b990%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rene Vallecillo

unread,
Apr 25, 2017, 7:14:11 AM4/25/17
to bleve
Marty, would you mind sharing just a small code sample please? 


On Friday, January 27, 2017 at 2:54:46 PM UTC-6, Marty Schoch wrote:
In general trying to filter out undesirable search results after the search has been completed is problematic.  It means you give up features like pagination, because you never know how many items to request, since you end up throwing some away.

A better approach is to index this additional data, and add the filters to the users search query.  So, in your example, if you index a field with each item called "store" using the keyword analyzer (because you only want exact matches on it).  Then when a user searches for X, you instead do the following search:

Conjunction combining
  - Users search X
  - Disjunction consisting of one or more TermSearch for store IDs the user should have access to

Let me know if this isn't clear or if you have more questions about this approach.

marty
On Wed, Jan 25, 2017 at 5:06 AM, Benjamin BALET <benjami...@gmail.com> wrote:
Hi,

I'm experimenting bleve on an inventory project that allows a global search on all stores. But users can view only the items stored in stores they are granted to access.

My initial solution was to iterate on the searchresults / Hits array and to build a new array by appending only the items users can view (Bleve Doc ID is a joined string of Item ID and storage ID).

I was just wondering if there is a way to safely delete some Hits or another solution.

Benjamin

--
You received this message because you are subscribed to the Google Groups "bleve" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bleve+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages