I'm querying neo4j's auto index several times trying to retrieve nodes by the property ID. It works well most of the time, but if my query contains a lucene special character (+ - && || ! ( ) { } [ ] ^ " ~ * ? : ) I get a ParseException.
I tried to parse the query string with the following code (as suggested here):
String escapeChars ="[\\\\+\\-\\!\\(\\)\\:\\^\\]\\{\\}\\~\\*\\?]";
String escaped = userInput.replaceAll(escapeChars, "\\\\$0");
As a result, the index query returns null.
Am I doing something wrong? Is there better way of escaping those characters?
Edit:
I also tried using Lucene's QueryParser.escape(query)
method with no luck.