Hi,
I am using Solr v1.4 and SolrJ on the client side.
I am not sure how SolrJ behaves regarding "escaping" special characters
[1] in a query string.
SolrJ does URL encoding of the query string it sends to Solr.
Do I need to escape special characters [1] when I construct a SolrQuery
object or not?
For example, if I want to search for "http://example.com#foo" in a
"uri" field, should I use:
(a) SolrQuery query = new SolrQuery("uri:http://example.com#foo");
(b) SolrQuery query = new SolrQuery("uri:http\\://example.com#foo");
which become respectively:
(a') q=uri%3Ahttp%3A%2F%2Fexample.com%23foo
(b') q=uri%3Ahttp%5C%3A%2F%2Fexample.com%23foo
My understanding is that SolrJ users are supposed to escape special
characters, therefore (b) is the correct way.
If this is the case, what's the best way to escape a query string which
might contain field names and URIs in their field values?
Thanks,
Paolo
[1]
http://lucene.apache.org/java/2_9_1/queryparsersyntax.html#Escaping%20Special%20Characters