protected Query endsWith(Operation<?> operation, QueryMetadata metadata,
            boolean ignoreCase) {
        verifyArguments(operation);
        Path<?> path = getPath(operation.getArg(0));
        String field = toField(path);
        String[] terms = convertEscaped(path, operation.getArg(1), metadata);
        if (terms.length > 1) {
            BooleanQuery bq = new BooleanQuery();
            for (int i = 0; i < terms.length; ++i) {
                String s = i == terms.length - 1 ? "*" + terms[i] : "*"
                        + terms[i] + "*";
                bq.add(new WildcardQuery(new Term(field, s)), Occur.MUST);
            }
            return bq;
        }
        return new WildcardQuery(new Term(field, "*" + terms[0]));
    }
If the query is a BooleanQuery and it contains a single Occur.MUST_NOT
clause it will be returned as is. Otherwise it will be wrapped in a
BooleanClause with the given Occur.
querydsl-lucene5/src/main/java/com/querydsl/lucene5/LuceneSerializer.java