the post_filter is unset in Query if Terms is used post_filter
rivaldowhd opened this issue · 1 comments
rivaldowhd commented
$query = new \Elastica\Query();
// set Terms as post_filter
$terms = new \Elastica\Query\Terms("key", ['term']);
$query->setPostFilter($terms);
// Query::toArray() will unset post_filter because count($terms) is 0 now, thus always ignoring the post_filter
$search->setQuery($query);
$search->search();
the _params should be set correctly in the construct
Terms:__construct()
{
...
if ($terms)
$this->setParam($this->field, $this->terms)
}
Or, the temporary workaround is to call $terms->toArray() right after the Terms is initialized.
deguif commented
@rivaldowhd Thanks for sharing the issue with the terms query.
It should be fixed by #2032