lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shaun A Elliott (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LUCENE-6221) escape operators
Date Thu, 05 Feb 2015 22:18:38 GMT
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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message