protected static Query createQueryForNodesWithFieldLike(String likeExpression,
                                                            String fieldName,
                                                            Function<String, String> caseOperation) {
        assert likeExpression != null;
        assert likeExpression.length() > 0;
        
        if (!QueryUtil.hasWildcardCharacters(likeExpression)) {
            // This is not a like expression, so just do an equals ...
            return createQueryForNodesWithFieldEqualTo(likeExpression, fieldName, caseOperation);
        }
        if (caseOperation == null) {
            // We can just do a normal Wildcard query ...
            
            // '%' matches 0 or more characters
            // '_' matches any single character
            // '\x' matches 'x'
            // all other characters match themselves
            
            // Wildcard queries are a better match, but they can be slow and should not be used
            // if the first character of the expression is a '%' or '_' or '*' or '?' ...
            char firstChar = likeExpression.charAt(0);
            if (firstChar != '%' && firstChar != '_' && firstChar != '*' && firstChar != '?') {
                // Create a wildcard query ...
                return new WildcardQuery(new Term(fieldName, toWildcardExpression(likeExpression)));
            }
        }
        // Create a regex query...
        String regex = QueryUtil.toRegularExpression(likeExpression);
        Pattern pattern = Pattern.compile(regex, Pattern.UNICODE_CASE);
        return new RegexQuery(fieldName, pattern, caseOperation);
    }
protected static Query createQueryForNodesWithFieldLike ( String likeExpression , String fieldName , Function < String , String > caseOperation ) { assert likeExpression != null ; assert likeExpression . length ( ) > 0 ; if ( ! QueryUtil . hasWildcardCharacters ( likeExpression ) ) { return createQueryForNodesWithFieldEqualTo ( likeExpression , fieldName , caseOperation ) ; } if ( caseOperation == null ) { char firstChar = likeExpression . charAt ( 0 ) ; if ( firstChar != '%' && firstChar != '_' && firstChar != '*' && firstChar != '?' ) { return new WildcardQuery ( new Term ( fieldName , toWildcardExpression ( likeExpression ) ) ) ; } } String regex = QueryUtil . toRegularExpression ( likeExpression ) ; Pattern pattern = Pattern . compile ( regex , Pattern . UNICODE_CASE ) ; return new RegexQuery ( fieldName , pattern , caseOperation ) ; }
Construct a {@link Query} implementation that scores documents with a string field value that is LIKE the supplied
constraint value, where the LIKE expression contains the SQL wildcard characters '%' and '_' or the regular expression
wildcard characters '*' and '?'.

@param likeExpression the LIKE expression; may not be null
@param fieldName the name of the document field containing the value; may not be null
@param caseOperation the operation that should be performed on the indexed values before the constraint value is being
evaluated; may be null which indicates that no case conversion should be done
@return the query; never null