lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan McKinley <ryan...@gmail.com>
Subject Re: Does SOLR provide a java class to perform url-encoding
Date Tue, 25 May 2010 23:01:04 GMT
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 Tue, May 25, 2010 at 1:58 PM, JohnRodey <timothyddaly@yahoo.com> wrote:
>
> 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 = URLEncoder.encode(s1, "UTF-8");
> String encoded2 = URLEncoder.encode(s2, "UTF-8");
> System.out.println(encoded1);
> System.out.println(encoded2);
> Output:
> %22mr.+bill%22+oh+n%3F
> %5C%22mr.+bill%5C%22+oh+n%5C%3F
>
> Should I allow the URLEncoder to translate s1, then replace %22 with ", %3F
> with ?, and so on?
> Or is there a better way?
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Does-SOLR-provide-a-java-class-to-perform-url-encoding-tp842660p842744.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Mime
View raw message