lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Harwood <>
Subject Re: Using filters to speed up queries
Date Sat, 23 Oct 2010 22:44:15 GMT
Look at BooleanQuery with 2 "must" clauses - one for the query, one for a ConstantScoreQuery
wrapping the filter.
BooleanQuery should then use automatically use skips when reading matching docs from the main
query and skip to the next docs identified by the filter.
Give it a try, otherwise you may be looking at using separate indexes

On 23 Oct 2010, at 23:18, Khash Sajadi wrote:

> My index contains documents for different users. Each document has the user id as a field
on it.
> There are about 500 different users with 3 million documents.
> Currently I'm calling Search with the query (parsed from user) and FieldCacheTermsFilter
for the user id.
> It works but the performance is not great.
> Ideally, I would like to perform the search only on the documents that are relevant,
this should make it much faster. However, it seems Search(Query, Filter) runs the query first
and then applies the filter.
> Is there a way to improve this? (i.e. run the query only on a subset of documents)
> Thanks

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message