lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain <>
Subject Set a field as required in a MultiFieldQueryParser
Date Sun, 01 Feb 2009 10:33:08 GMT
Hello everybody,

I have a search app in which the user can specify in which category the
documents he's searching are. So all my indexed documents have a
"category" field as well as other fields such as title, description,
etc. So when the user enters his query, only the documents that are in
the given category and which match a part of the query must be returned.

So I tried to use a MultiFieldQueryParser with SHOULD clauses on the
title, description, etc and a MUST clause on the category field. It
works pretty well but the problem is that _all_ the documents in the
searched category are returned, even if they don't have any similarity
with the search string (except for the category of course).

I think that's because of the MUST field which takes precedence on the
SHOULD fields or something like that ? I saw in the BooleanQuery the
method setMinimumNumberShouldMatch(). I think I should use this with my
MultiFieldQueryParser to set a minimum of 1 or 2 fields, but this method
only exists for BooleanQuery instances so I can't use it... I thought
about using directly a BooleanQuery but I want to use the FrenchAnalyzer
for the request.

Any idea on how to achieve this ?

Thanks for your help !

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

View raw message