java.lang.Object
org.elasticsearch.xpack.core.ml.utils.MlStrings

public final class MlStrings extends Object
Another String utilities class. Class name is prefixed with Ml to avoid confusion with one of the myriad String utility classes out there.
  • Field Details

  • Method Details

    • doubleQuoteIfNotAlphaNumeric

      public static String doubleQuoteIfNotAlphaNumeric(String input)
      Surrounds with double quotes the given input if it contains any non-word characters. Any double quotes contained in input will be escaped.
      Parameters:
      input - any non null string
      Returns:
      input when it does not contain non-word characters, or a new string that contains input surrounded by double quotes otherwise
    • isValidId

      public static boolean isValidId(String id)
    • hasValidLengthForId

      public static boolean hasValidLengthForId(String id)
      Checks if the given id has a valid length. We keep IDs in a length shorter or equal than ID_LENGTH_LIMIT in order to avoid unfriendly errors when storing docs with more than 512 bytes.
      Parameters:
      id - the id
      Returns:
      true if the id has a valid length
    • getParentField

      public static String getParentField(String fieldPath)
      Returns the path to the parent field if fieldPath is nested or fieldPath itself.
      Parameters:
      fieldPath - a field path
      Returns:
      the path to the parent field if {code fieldPath} is nested or fieldPath itself
    • findMatching

      public static Set<String> findMatching(String[] patterns, Set<String> items)
      Given a collection of strings and some patterns, it finds the strings that match against at least one pattern.
      Parameters:
      patterns - the patterns may contain wildcards
      items - the collections of strings
      Returns:
      the strings from items that match against at least one pattern