presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchQueryBuilder.java/ElasticsearchQueryBuilder/buildSearchQuery
class ElasticsearchQueryBuilder:    public static QueryBuilder buildSearchQuery(TupleDomain<ColumnHandle> constraint, List<ElasticsearchColumnHandle> columns, Optional<String> query)
    {
        BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
        for (ElasticsearchColumnHandle column : columns) {
            BoolQueryBuilder columnQueryBuilder = new BoolQueryBuilder();
            Type type = column.getType();
            if (constraint.getDomains().isPresent()) {
                Domain domain = constraint.getDomains().get().get(column);
                if (domain != null) {
                    columnQueryBuilder.should(buildPredicate(column.getName(), domain, type));
                }
            }
            boolQueryBuilder.must(columnQueryBuilder);
        }

        query.map(QueryStringQueryBuilder::new)
                .ifPresent(boolQueryBuilder::must);

        if (boolQueryBuilder.hasClauses()) {
            return boolQueryBuilder;
        }
        return new MatchAllQueryBuilder();
    }