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 Fri, 29 Feb 2008 08:41:10 GMT
Hash: SHA1

Thanks a lot for your help Daniel, I have found a solution :)

The 'token' field is public inside QueryParser, and inside
'token.image' you can read the origin String with apostrophe.

Thus, I can differ between the two situations - and simply
return a BooleanQuery in the case there is no apostrophe.

best regards


Daniel Noll schrieb:
| On Wednesday 27 February 2008 00:50:04 wrote:
|> Looks that this is really hard-coded behaviour, and not Analyzer-specific.
| The whitespace part is coded into QueryParser.jj, yes.  So are the quotes
| and : and other query-specific things.
|> I want to search for directories with tokenizing them, e.g.
|> /home/reuschling - this seems to be not possible with the current
|> queryparser.
| That's possible by changing the analyser.  For instance StandardAnalyzer will
| tokenise that as two terms, but WhitespaceAnalyzer will tokenise it as one.
|> | If you subclass QueryParser than you can override this method and modify
|> | it to do whatever evil trick you want to do.
|> Overriding getFieldQuery() will not work because I can't differ between
|> "home/reuschling", which should trigger a PhraseQuery, and home/reuschling
|> without apostrophe, which should trigger a BooleanQuery...I will search
|> whether I can find a better place for this:)
| That much is true.  Likewise, there is no difference between quoting "cat" and
| typing cat without quotes.
| You could possibly override the parse(String) method and mangle the string in
| some way so that you know.  So if the user enters /a/b it could pass
| down /a/b, but if they enter "/a/b" it could pass down "SOMETHING/a/b", and
| you then detect the SOMETHING in getFieldQuery.  Just have to make sure the
| something isn't tokenised out by the analyser.
| Or you could clone QueryParser.jj itself and modify it to call different
| methods for the two situations.
| 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