Class MlStrings
- java.lang.Object
-
- org.elasticsearch.xpack.core.ml.utils.MlStrings
-
public final class MlStrings extends java.lang.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 Summary
Fields Modifier and Type Field Description static int
ID_LENGTH_LIMIT
-
Method Summary
Modifier and Type Method Description static java.lang.String
doubleQuoteIfNotAlphaNumeric(java.lang.String input)
Surrounds with double quotes the giveninput
if it contains any non-word characters.static java.lang.String
getParentField(java.lang.String fieldPath)
Returns the path to the parent field iffieldPath
is nested orfieldPath
itself.static boolean
hasValidLengthForId(java.lang.String id)
Checks if the givenid
has a valid length.static boolean
isValidId(java.lang.String id)
-
-
-
Field Detail
-
ID_LENGTH_LIMIT
public static final int ID_LENGTH_LIMIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
doubleQuoteIfNotAlphaNumeric
public static java.lang.String doubleQuoteIfNotAlphaNumeric(java.lang.String input)
Surrounds with double quotes the giveninput
if it contains any non-word characters. Any double quotes contained ininput
will be escaped.- Parameters:
input
- any non null string- Returns:
input
when it does not contain non-word characters, or a new string that containsinput
surrounded by double quotes otherwise
-
isValidId
public static boolean isValidId(java.lang.String id)
-
hasValidLengthForId
public static boolean hasValidLengthForId(java.lang.String id)
Checks if the givenid
has a valid length. We keep IDs in a length shorter or equal thanID_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 java.lang.String getParentField(java.lang.String fieldPath)
Returns the path to the parent field iffieldPath
is nested orfieldPath
itself.- Parameters:
fieldPath
- a field path- Returns:
- the path to the parent field if {code fieldPath} is nested or fieldPath itself
-
-