Ignore my comment about using the same analyzer. My addled mind at fault.
You are getting the correct query as far as QueryParser is concerned.
"(wind window)" should match on both wind and window. You will only get
a boolean query back if the total position difference in the tokens is
1. In your example case the total positional difference is 0...thus the
MultiPhraseQuery. It seems odd, but to get the boolean should back you
need to have multiple tokens at the same position and a total
poistionIncrement of 1. Say "wind man" which would give wind:position0
window:position0 man:position1 ... now you have multiple tokens at the
same position and a total positional increment of 1...you'll get all 3
tokens back in a SHOULD boolean. Frankly this seems odd to me. Maybe I
am off base. Either way...QueryParser is giving you the query that you
should expect from it.
Mark Miller
Alice wrote:
No.. I am not indexing and searching with the same analyzer.
The reason I do this is because I want to index exactly the contents I have
in my database.
This is used to find some products the company sells, and the users don’t
write their names correctly, so if they type something that is contained in
any producted I assume that keyword as a synonym.
Like: keyword.indexOf(myProduct) != -1 --> it’s a synonym.
So, when I search I use the SynonymAnalyzer.
But my intention as the analyzer returns by example the tokens 'wind' and
'window' was to have a query that would do:
Contents:wind contents:window
-----Original Message-----
From: Mark Miller [mailto:[EMAIL PROTECTED]
Sent: terça-feira, 5 de dezembro de 2006 19:08
To: java-user@lucene.apache.org
Subject: Re: Customized Analyzer
Just took a quick peak at the MultiPhraseQuery toString() and it does
indeed wrap the query in quotes (it also puts in the parenthesis). You
are generating a MultiPhraseQuery. Is that not your intent?. The
QueryParser will generate a MultiPhraseQuery when more than one token
with different positions are emmited from the analyzer and at least one
of the positions has multiple tokens associated with it. I believe this
should be a pretty common phenomenon with a synonym analyzer.
I would look into your Analyzer...my guess is that it has not been
perfected. You are indexing and searching with the same analyzer, correct?
- Mark Miller
Alice wrote:
It does not work.
Even with the synonyms indexed it is not found.
That's why my guess was to remove the "" but I don’t know how.
-----Original Message-----
From: Daniel Naber [mailto:[EMAIL PROTECTED]
Sent: terça-feira, 5 de dezembro de 2006 18:34
To: java-user@lucene.apache.org
Subject: Re: Customized Analyzer
On Tuesday 05 December 2006 20:14, Alice wrote:
It returns
content:"(wind window)"
That might be the correct representation of a MultiPhraseQuery. So does
your query work anyway? It's just that you cannot use QueryParser again to
parse this output (similar to some other queries like SpanQueries whose
toString() representation also cannot be parsed again).
Regards
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]