Back in November, I blogged about how to use Egeria’s ‘find’ methods to search for entities and relationships.
That article introduced the Metadata Collection interface find methods (e.g.
findRelationshipsByPropertyValue). It also discussed the
OMRSRepositoryHelper methods that can be used to generate a search expression to pass to the ‘find’ methods. Each helper method constructs a regular expression that can be used to narrow a search, by looking for a property value that is an ‘exact match’, or that contains the search string at the start, in the end, or somewhere in the middle.
The helper methods accept the string to search for and return a regular expression. For example:
getExactMatchRegex(String searchString) returns a regular expression to match a whole property value to the specified searchString.
getContainsRegex(String searchString) returns a regular expression to match a property value that contains the specified searchString.
Up till release 1.6, these methods were case-sensitive. From release 1.7 of Egeria, the helper methods have been extended to provide a case-insensitive option. In addition to the existing methods, there are now variants such as:
getExactMatchRegex(String searchString, boolean insensitive) which returns a regular expression similar to the above that, if the
insensitive flag is
true , will match values with any case.
getExactMatchRegex("schemaanalysis", true) will produce the regular expression
"(?i)\Qschemaanalysis\E" where the
"(?i)" part is the Java 1.8 Pattern match flag for case-insensitive matching.
This expression would match any of the following values:
"SCHEMAANALYSIS" , etc.
The existing caveat applies – to not use the helper methods to generate complex expressions from strings that already contain the
\E escape characters. A similar caveat applies to the case-insensitive flag, which will always occur once, pre-pended to the search string and be applied to the whole string.
Also in release 1.7, the Egeria-provided repositories support the use of the new regular expressions generated by the
OMRSRepositoryHelper methods to perform case-insensitive matches.