Rezgar Cadro
Rezgar Cadro

Reputation: 401

How to combine BooleanQuery and Filter for Lucene?

I'm wondering if there's a way to perform a filtered search in Lucene index with a combination of Filter and Query instead of a BooleanQuery?

Since performing a query causes calculation of relevance rating, we don't really need this when filtering documents by category or location.

For example: we have a query "happy new year" which should be performed within "Greeting Cards / XMas" category. So what we really need is to do a search within the category and then order the results by a relevance rating, based on a query text.

If we try to do it with a BooleanQuery, relevance rating calculation considers every term in a query (if I understand the mechanics correctly).

Upvotes: 1

Views: 1336

Answers (1)

Xodarap
Xodarap

Reputation: 11849

See the api - note how you can pass in both a filter and a query.

Upvotes: 1

Related Questions