Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-6221

escape whole word operators (OR, AND, NOT)

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/queryparser
    • Labels:
      None
    • Lucene Fields:
      New

      Description

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

        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();
        }
      

      It would be better if these words were escaped too.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              javamonkey79 Shaun A Elliott
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: