lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: When does QueryParser creates PhraseQueries
Date Tue, 26 Feb 2008 09:54:16 GMT
Hash: SHA1

Daniel, thank you very much for the hint!

I stepped through the code and tried some scenarios.

when I type in with whitespace delimiters
~      termA termB
this will result into two invocations of getFieldQuery, one for each term.

when I type
~      termA/termB
~     "termA termB"
this will result into one invocation of getFieldQuery for the whole String.

Why makes the parser a difference between termA/termB and termA termB?
The Analyzer tokenizes between both delimiters.


Daniel Noll schrieb:
| On Tuesday 26 February 2008 01:05:27 wrote:
|> Hi all,
|> I have the behaviour that when I search with Luke (version 0.7.1, Lucene
|> version 2.2.0) inside an arbritray field, the QueryParser creates a
|> PhraseQuery when I type in
|> ~              termA/termB      (no "...")
|> When I read the documentation at the Lucene webside, I only find the syntax
|> ~             "termA termB"
|> for creating phrase queries.
|> Did I make a mistake? Can I configure the QueryParser that he simply
|> tokenizes between termA and termB, and makes a simple BooleanQuery as he do
|> in the case of a whitespace delimiter?
| You'll find they both go through getFieldQuery() as-is.  The default
| implementation of that runs the string through the analyser; if it happens to
| return more than one token then it will create a PhraseQuery instead of a
| TermQuery.
| If you subclass QueryParser than you can override this method and modify it to
| do whatever evil trick you want to do.
| Daniel
| ---------------------------------------------------------------------
| To unsubscribe, e-mail:
| For additional commands, e-mail:
Version: GnuPG v2.0.4-svn0 (GNU/Linux)


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

View raw message