Class QueryPreprocessor

java.lang.Object
org.opencastproject.elasticsearch.index.QueryPreprocessor

public final class QueryPreprocessor extends Object
Utility class to preprocess potentially malformed Lucene query strings. The following sanitations are performed: - Escape special characters that would potentially lead to malformed queries - Enable partial search by adding '*' as both prefix and suffix to individual terms - Exception: Double-quoted terms - Sanitize use of double quotes by appending a double quote at the end of the sanitized query in case the closing double quote is missing - Ensure that + und - are interpreted in a user-friendly way, i.e. test-unit is not interpreted as test -unit
  • Method Details

    • sanitize

      public static String sanitize(String query)
      Sanitize a potentially malformed query string so it conforms to the Lucene query syntax
      Parameters:
      query - potentially malformed Lucene query string
      Returns:
      sanitized query string