public static Predicate<String> createCaseInsensitiveContainsPredicate(final String userInput) {
        if (userInput == null) {
            return stringUnderTest -> true;
        } else {
            final String lowerCaseInput = userInput.toLowerCase();
            return toNullSafePredicate(false, stringUnderTest ->
                    stringUnderTest.toLowerCase().contains(lowerCaseInput));
        }
    }
For a given user input this method will return a function that can evaluate a string to see how
good the match is. The quality of the match is determined by the length of the matched region
(shorter == better) and its distance from the start of the string (closer == better).
stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/StringPredicateFactory.java