As always, the best things to do are to know exactly what you indexed
(AnalyzerDemo from Lucene in Action helps here, and of course the
wonderful tool, Luke). Then try simplifying your query to a
TermQuery for a term you know or suspect you indexed. QueryParser
introduces a lot of variables to the equation, such as operators and
special characters that get interpreted by the parser itself,
escaping rules, and analysis - not to mention the Query.toString()
issue you've discovered.
Erik
On Dec 20, 2005, at 4:14 PM, John Powers wrote:
Ok, I understand the .toString() part.
But, if I have some 19" in the text of these items, and I do a
search with
19", that has been escaped before parsing....why am I not getting
anything?
The indexer analyzer took them out? So then to find these
documents, I
would want to either change the analyzer or take the quote out of
the query?
Correct?
On 12/20/05 12:07 PM, "Yonik Seeley" <[EMAIL PROTECTED]> wrote:
On 12/20/05, John Powers <[EMAIL PROTECTED]> wrote:
I would like to be able to search for 19 inches with the quote.
So I get a
query like this:
Line 1: +( (name:19"*^4 ld:19"*^2 sd:19"*^3 kw:19"*^1) )
That won't work, so I wanted to escape the quotes. The docs
said to use a
backslash. So I'm doing this:
luceneQuery.toString().replaceAll("\"", "\\\\\"")
It should be " => \",
so shouldn't that be luceneQuery.toString().replaceAll("\"", "\\\"")
And the result is:
Line 2: +( (name:19\"*^4 ld:19\"*^2 sd:19\"*^3 kw:19\"*^1) )
This looks right. Then I put it into a
MultiFieldQueryParser.parse() via:
query =
MultiFieldQueryParser.parse(luceneQuery.toString().replaceAll("\"",
"\\\\\""), Indexer.CARTABLE, Indexer.analyzer);
and I get:
Parsed query: +(name:19"*^4.0 ld:19"*^2.0 sd:19"*^3.0 kw:19"*)
This looks right.
Which of course, won't work. How can I get the escapes to
survive through
the parsing?
The escapes are for parsing. You don't want them to survive parsing
unless you also indexed them with escapes.
Perhaps what is causing your confusion is that Query.toString()
doesn't currently re-escape special characters.
-Yonik
---------------------------------------------------------------------
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]