java.lang.Object
org.elasticsearch.xpack.core.ml.utils.MlStrings
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic StringSurrounds with double quotes the giveninputif it contains any non-word characters.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.static StringgetParentField(String fieldPath) Returns the path to the parent field iffieldPathis nested orfieldPathitself.static booleanChecks if the givenidhas a valid length.static boolean
-
Field Details
-
ID_LENGTH_LIMIT
public static final int ID_LENGTH_LIMIT- See Also:
-
-
Method Details
-
doubleQuoteIfNotAlphaNumeric
Surrounds with double quotes the giveninputif it contains any non-word characters. Any double quotes contained ininputwill be escaped.- Parameters:
input- any non null string- Returns:
inputwhen it does not contain non-word characters, or a new string that containsinputsurrounded by double quotes otherwise
-
isValidId
-
hasValidLengthForId
Checks if the givenidhas a valid length. We keep IDs in a length shorter or equal thanID_LENGTH_LIMITin order to avoid unfriendly errors when storing docs with more than 512 bytes.- Parameters:
id- the id- Returns:
trueif the id has a valid length
-
getParentField
Returns the path to the parent field iffieldPathis nested orfieldPathitself.- Parameters:
fieldPath- a field path- Returns:
- the path to the parent field if {code fieldPath} is nested or fieldPath itself
-
findMatching
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 wildcardsitems- the collections of strings- Returns:
- the strings from
itemsthat match against at least one pattern
-