erichard / elasticsearch-query-builder

Build query for an ElasticSearch client using a fluent interface
MIT License
39 stars 20 forks source link

Possible bug (or unclear mechanics) #3

Closed StarveTheEgo closed 2 years ago

StarveTheEgo commented 6 years ago

This is the deer again!

I think i've found possible pug. Or i am just missing the logic in this code: src/QueryBuilder.php:112

if (!empty($this->filters)) {
    $query['body']['query'] = [];
    foreach ($this->filters as $filter) {
        $query['body']['query'] = $filter->build();
    }
}

This part makes me feel weird. $this->filters is an array, we iterate it, but rewriting $query['body']['query'] instead of appending (or whatever it should be).

erichard commented 6 years ago

Good catch ! You are right. It not really make sense to have an array of filter. I don't even think you can pass multiples queries. I think we need a BoolQuery to do that.

Also there is a naming issue here I think, filters is not a good name for this.

erichard commented 2 years ago

Closing as 3.0 fix all of these is issues