I'm trying to search documents by title with StandardAnalyzer of lucene 4.10.3. I read the quotes from a file and the I add the double quotation marks for constructing the query with this:
Query query = parser.parse("\""+doc.get("title")+"\"");
The problem is that when it reads the quote PHILIPPINES SAYS DEBT PACT "BETTER THAN MEXICO'S lucene returns this error
Cannot parse '"PHILIPPINES SAYS DEBT PACT "BETTER THAN MEXICO'S"': Lexical error at line 1, column 52. Encountered: <EOF> after : ""
How can I solve it?
Thanks!
The problem is that the quote in the text you are searching for needs to be escaped. You can escape text to be searched using
QueryParser.escape
: