You may also want to look at:
ClientUtils.escapeQueryChars( String s )
http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/util/ClientUtils.html#escapeQueryChars%28java.lang.String%29
this will escape any lucene query chars, then pass it to URLEncoder
and you should be good to go.
On
I was assuming that I needed to leave the special characters in the http get,
but running the solr admin it looks like it converts them the same way that
URLEncoder.encode does. What is the need to preserve special characters?
http://localhost:8983/solr/select?indent=on&version=2.2&q=%22mr.+bill
Thanks Sean, that was exactly what I need. One question though...
How to correctly retain the Solr specific characters.
I tried adding escape chars but URLEncoder doesn't seem to care about that:
Example:
String s1 = "\"mr. bill\" oh n?";
String s2 = "\\\"mr. bill\\\" oh n\\?";
String encoded1
Java provides one. You probably want to use utf-8 as the encoding scheme.
http://java.sun.com/javase/6/docs/api/java/net/URLEncoder.html
Note you also will want to strip or escape character that are meaningful
in the Solr/Lucene query syntax.
http://lucene.apache.org/java/2_4_0/queryparsersyn