You have to escape the special characters.Use the below method to escape public static String escapeQueryChars(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 == ';' || Character.isWhitespace(c)) { sb.append('\\'); } sb.append(c); } return sb.toString(); }
-----Original Message----- From: "pawan.darira [via Lucene]" <ml-node+1943780-1932990465-225...@n3.nabble.com> Sent: Monday, November 22, 2010 12:39am To: "sivaprasad" <sivaprasa...@echidnainc.com> Subject: Phrase Search & Multiple Keywords with Double quotes Hi I want to do pharse searching with single/double quotes. Also there are cases that those phrases include special characters like & etc. What all i need to do while indexing such special characters & while searching them. How to handle phrase search with quotes Please suggest -- Thanks, Pawan Darira View message @ [http://lucene.472066.n3.nabble.com/Phrase-Search-Multiple-Keywords-with-Double-quotes-tp1943780p1943780.html] http://lucene.472066.n3.nabble.com/Phrase-Search-Multiple-Keywords-with-Double-quotes-tp1943780p1943780.html To start a new topic under Solr - User, email ml-node+472068-1030716887-225...@n3.nabble.com To unsubscribe from Solr - User, [http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=472068&code=c2l2YXByYXNhZC5qQGVjaGlkbmFpbmMuY29tfDQ3MjA2OHwtMjAyODMzMTY4OQ==] click here. -- View this message in context: http://lucene.472066.n3.nabble.com/Phrase-Search-Multiple-Keywords-with-Double-quotes-tp1943780p1943793.html Sent from the Solr - User mailing list archive at Nabble.com.