You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Shahak Nagiel <sn...@yahoo.com> on 2013/11/18 19:35:12 UTC
QueryParser.Operator with BooleanQuery
Initially, I queried our (v4.4) index with a single MultiFieldQueryParser and Operator.AND to ensure that all search terms appeared in the results.
Since then, however, we've needed to query more flexibly, using a BooleanQuery to merge several subqueries (in order to apply different analyzers to different fields/field groups). As a result, we've had to switch to Operator.OR, since there was no guarantee that all search terms would apply to/match every clause of the boolean query.
Consequently, there's more "noise" in the returned results, since many of them don't contain ALL the original search terms.
So, is there a way to enforce this AND/MUST policy in a cumulative sense across all subqueries (i.e. filter out results which don't match all search terms)?
Thanks!
Re: QueryParser.Operator with BooleanQuery
Posted by Alan Woodward <al...@flax.co.uk>.
Hi Shahak,
BooleanQuery.setMinimumNumberShouldMatch might help you here.
Alan Woodward
www.flax.co.uk
On 18 Nov 2013, at 18:35, Shahak Nagiel wrote:
> Initially, I queried our (v4.4) index with a single MultiFieldQueryParser and Operator.AND to ensure that all search terms appeared in the results.
>
> Since then, however, we've needed to query more flexibly, using a BooleanQuery to merge several subqueries (in order to apply different analyzers to different fields/field groups). As a result, we've had to switch to Operator.OR, since there was no guarantee that all search terms would apply to/match every clause of the boolean query.
>
> Consequently, there's more "noise" in the returned results, since many of them don't contain ALL the original search terms.
>
> So, is there a way to enforce this AND/MUST policy in a cumulative sense across all subqueries (i.e. filter out results which don't match all search terms)?
>
> Thanks!