You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Bram Van Dam <br...@intix.eu> on 2014/11/10 11:01:16 UTC

Filter Query or Query

Hi folks,

I have an index with hundreds of millions of documents, which users can 
query in various ways.

Two index fields are used by the system to hide certain documents from 
certain users (for instance: Department A can only view documents 
belonging to Department A, but not Department B).

We're currently doing something like this:

query = userQuery AND department:userDepartment

I'm wondering if perhaps a filter query might be a better fit?

query = userQuery
filterQuery = department:userDepartment

This feels a lot cleaner, but I'm worried about the performance 
implications. Some users have access to all documents, which might be a 
bit painful for the filter cache? Or am I missing something?

Thanks,

  - Bram

Re: Filter Query or Query

Posted by Erik Hatcher <er...@gmail.com>.
Filter queries are the right thing to use here.  It allows the filters to cache separately from the query and will provide, possibly dramatic, performance improvements.  Don't worry about the caching concern - you'll have far fewer caches when the filter constraints are separate from the user query. 

   Erik


> On Nov 10, 2014, at 05:01, Bram Van Dam <br...@intix.eu> wrote:
> 
> Hi folks,
> 
> I have an index with hundreds of millions of documents, which users can query in various ways.
> 
> Two index fields are used by the system to hide certain documents from certain users (for instance: Department A can only view documents belonging to Department A, but not Department B).
> 
> We're currently doing something like this:
> 
> query = userQuery AND department:userDepartment
> 
> I'm wondering if perhaps a filter query might be a better fit?
> 
> query = userQuery
> filterQuery = department:userDepartment
> 
> This feels a lot cleaner, but I'm worried about the performance implications. Some users have access to all documents, which might be a bit painful for the filter cache? Or am I missing something?
> 
> Thanks,
> 
> - Bram