lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: Question: force a field must be matched?
Date Thu, 15 Sep 2005 18:45:19 GMT
: I wonder if that's the same as
:
:   queryString + " publisher:Manning"
:
: and pass on to the query parser?

assuming queryString is a java variable containing your initial query,
then you are close, but not quite.  If you want to tell QueryParser to
make a clause "required" then you have to prefice it with a "+".

something like...

  String userQueryString = ...;
  String queryString = userQueryString + " +publisher:Manning";

...is probably what you want.

Alternately, instead of giving QueryParser a string you have built up
from little pieces, I would recommend that you let QueryParser build a
Query just off of the user input, and then either:

  a) Filter that query at search time (take a look at the Filter class and
     it's subclasses)
  b) Modify the Query object returned by the QueryParser -- either adding
     a mandatory clause to it if it's a BooleanQuery, or wrapping it in a
     new BooleanQuery that already contains your required clause.


-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message