private Query buildKeywordQuery(final String fieldName, final String expression) {
        final Matcher quotedMatcher = QUOTED_PATTERN.matcher(expression);
        if (quotedMatcher.matches()) {
            // Expression is in quotes, so perform an exact match
            return QueryBuilders.term(q -> q
                    .field(fieldName)
                    .value(quotedMatcher.group(1)));
        } else if (WILDCARD_PATTERN.matcher(expression).matches()) {
            // Expression is a wildcard pattern, so return a wildcard query
            return QueryBuilders.wildcard(q -> q
                    .field(fieldName)
                    .value(expression)
                    .caseInsensitive(true));
        } else {
            // Perform an exact match on the provided term
            return QueryBuilders.term(q -> q
                    .field(fieldName)
                    .value(expression));
        }
    }
Creates an Elasticsearch query for a `keyword` field appropriate for the expression content
stroom-search/stroom-search-elastic/src/main/java/stroom/search/elastic/search/SearchExpressionQueryBuilder.java