Skip to content

Commit f5fe2f8

Browse files
committed
Cleanup must filters
1 parent 9a0427e commit f5fe2f8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Hunter.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -423,20 +423,20 @@ public function getSearchParams($term, array $options = [])
423423

424424
// Check for must filters
425425
if ($filter_musts = Arr::get($options, 'filter_musts')) {
426-
foreach(array_filter($filter_musts) as $filter=>$value) {
426+
foreach($filter_musts as $filter=>$value) {
427427

428428
// TODO: This sucks...fix it. Version 2 made it so that
429429
// all tags had to be present, not just some of them
430430
if (is_array($value)) {
431-
foreach($value as $k=>$v) {
431+
foreach(array_filter($value) as $k=>$v) {
432432
$params['body']['query']['bool']['must'][] = [
433433
'term' => [
434434
$filter => $v,
435435
],
436436
];
437437
}
438438
}
439-
else {
439+
else if($value !== '') {
440440
$params['body']['query']['bool']['must'][] = [
441441
'term' => [
442442
$filter => $value,

0 commit comments

Comments
 (0)