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: Query String for a phrase?
Date Mon, 12 Mar 2007 20:36:28 GMT

: ok, so does that mean i can use both q1 and q2 for phrase query ie; for
: searching words adjacent to each other. Actually that was my only concern,
: as i wanted to use q1 for phrase query, rather than q2.
: Regards,

Your example "q1" is not hte correct syntax for a phrase query .. the
correct syntax is to put quotes arround your words.

you happen to be getting phrase queries for your "q1" example because of
the analyzer you are using.   QueryParser does one pass at parsing to
look for special meta characters it udnerstands, and then passes the
tokens it finds to your analyzer, if hte analyzer gives it back a
stream of tokens it makes  phrase query out of it... because your analyzer
splits "apaceh&lucene" into two tokens, QueryParser makes a phrase query.

you should not rely on this behavior, because if at some point your
analyzer changes (or if you are using StandardAnalyzer and it encounters a
situation where it assumes the "&" is a legitimate interword character (it
might in cases i can't think of off hte top of my head) you won't get a
phrase query, you'll get a single word query.

use the syntax documented to get the behavior documented: if you don't
like that syntax, you'll need a different query parser.


-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