Shaun A Elliott created LUCENE-6221:
---------------------------------------

             Summary: escape operators
                 Key: LUCENE-6221
                 URL: https://issues.apache.org/jira/browse/LUCENE-6221
             Project: Lucene - Core
          Issue Type: Improvement
          Components: core/queryparser
            Reporter: Shaun A Elliott


The current QueryParser escape method does not escape whole word operators (OR, 
AND, NOT):

{code}
  public static String escape(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('\\');
      }
      sb.append(c);
    }
    return sb.toString();
  }
{code}

It would be better if these words were escaped too.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to