lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: QueryParser behaviour ..
Date Fri, 10 Feb 2006 18:54:50 GMT

:  I built a wrong query string "word1,word2,word3" instead of "word1
: word2 word3"
: therefore I got a wrong query:  field:"word1 word2 word3" instead of
: field:word1 field:word2  field:word3.
:  Is this an espected behaviour?
:  I used Standard analyzer, probably therefore, the comas were replaced
: with spaces.

the commas weren't replaced ... your analyzer split on them and threw
them away.

they key to understanding why that resulted in a phrase query instead of
three term queries is that QueryParser doesn't treat comma as a special
character, so it saw the string word1,word2,word3 and gave it to your
analyzer.  Since your analyzer gave back several tokens QueryParser built
a phrase query out of it.

likewise, in the case of "word1 word2 word3" the quotes *are* a special
character to QueryParser which tells it it should *not* split on the
spaces betwen the quotes, and hand the individual words to the analyzer.
instead it hands the whole thing to the analyzer as one big string again.

:  Is this a bug? Does it make sense to indicate this situation through a
: Parse Exception?

a parse error should really onl come up when the query parser sees a
character that it does consider special, but sees it in a place that
doesn't make sense (or doesn't see one in a plkace it needs one).  in this
case QP is perfectly happy to let you query for a word that contains a
comma -- it's your analyzer that's putting it's foot down and saying that
can't be in a word.


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

View raw message