Yes, "+" is what I missed! Thanks.

Suppose there is a book published by 3 publishers (I
don't know how that works in real world):

// At index time:
  doc.add( Field.Keyword("publisher", "Manning") );
  doc.add( Field.Keyword("publisher", "SAMS") );
  doc.add( Field.Keyword("publisher", "O'Reilly") );

// At search time:
  queryString += " +publisher:SAMS";
  ...

should find me that Document.


--- Chris Hostetter <[EMAIL PROTECTED]> wrote:

> : 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:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 



                
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to