You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Matt Magoffin <ap...@msqr.us> on 2005/10/05 05:10:19 UTC

QueryParser exception on escaped double quote character

I'm having a problem getting the QueryParser to correctly parse a string
like the following:

addr:"Foo \"Bar\" Street"

Should this work, or is there some other way to escape double quotes
within a quoted query term? Here is a unit test that shows the problem:

import junit.framework.TestCase;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;

public class TestQueryParser extends TestCase {

	public void testLuceneEscapedQuotesBug() throws Exception {
		// this fails
		Query q = new QueryParser("foo",new StandardAnalyzer()).parse(
			"addr:\"My \\\"A\\\" Street\"");
	}

}


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: QueryParser exception on escaped double quote character

Posted by Yonik Seeley <ys...@gmail.com>.
Unfortunately, the QueryParser doesn't handle any escaping inside a quoted
string.
http://www.mail-archive.com/java-user@lucene.apache.org/msg02354.html

-Yonik
Now hiring -- http://tinyurl.com/7m67g

On 10/4/05, Matt Magoffin <ap...@msqr.us> wrote:
>
> I'm having a problem getting the QueryParser to correctly parse a string
> like the following:
>
> addr:"Foo \"Bar\" Street"
>
> Should this work, or is there some other way to escape double quotes
> within a quoted query term?