Escape Special characters in SOLR before Query
here is the function to escape the culprits
public static String escapeQueryCulprits(String s)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
// These characters are part of the query syntax and must be escaped
if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':'
|| c == '^' || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~'
|| c == '*' || c == '?' || c == '|' || c == '&' || c == ';'
)
{
sb.append('\\');
}
if(Character.isWhitespace(c))
{
sb.append(" \\ ");
}
sb.append(c);
}
return sb.toString();
}
Thursday, September 29, 2011
Wednesday, September 21, 2011
A partial block (3 of 4 bytes) was dropped in Base64 String
When you face such a issue just use
Flex :
encodeURIComponent(String) in flex
Java :
URIUtil.encodeQuery(String)
Before posting the string in Browser as "=" and "&" in the String create issue while decoding String.
Labels:
Adobe Flex,
Base64 String,
Encoding and Decoding,
java,
Varun Rathore
Subscribe to:
Posts (Atom)
About Me
- vrathore
- noida, dehli, India