Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Commit bfd8a66

Browse files
committed
Minor fixes
1 parent 181bfbf commit bfd8a66

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

src/Builders/FilterBuilder.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,14 @@ public function whereExists($field)
100100

101101
public function whereNotExists($field)
102102
{
103-
$this->wheres['must_not'][] = [
104-
'exists' => [
105-
'field' => $field
106-
]
107-
];
103+
$this->wheres['must_not'][] = ['exists' => ['field' => $field]];
108104

109105
return $this;
110106
}
111107

112108
public function whereRegexp($field, $value, $flags = 'ALL')
113109
{
114-
$this->wheres['must'][] = [
115-
'regexp' => [
116-
$field => [
117-
'value' => $value,
118-
'flags' => $flags
119-
]
120-
]
121-
];
110+
$this->wheres['must'][] = ['regexp' => [$field => ['value' => $value, 'flags' => $flags]]];
122111

123112
return $this;
124113
}

src/ElasticEngine.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,21 @@ protected function buildSearchQueryPayload(Builder $builder, $queryPayload, arra
5959
continue;
6060
}
6161

62-
$queryPayload = array_merge_recursive(
63-
$queryPayload,
64-
['filter' => ['bool' => [$clause => $filters]]]
62+
if (!array_has($queryPayload, 'filter.bool.'.$clause)) {
63+
array_set($queryPayload, 'filter.bool.'.$clause, []);
64+
}
65+
66+
$queryPayload['filter']['bool'][$clause] = array_merge(
67+
$queryPayload['filter']['bool'][$clause],
68+
$filters
6569
);
6670
}
6771

6872
$payload = (new TypePayload($builder->model))
6973
->setIfNotEmpty('body.query.bool', $queryPayload)
7074
->setIfNotEmpty('body.sort', $builder->orders)
71-
->setIfNotEmpty('body.explain', isset($options['explain']) ? $options['explain'] : null)
72-
->setIfNotEmpty('body.profile', isset($options['profile']) ? $options['profile'] : null);
75+
->setIfNotEmpty('body.explain', $options['explain'] ?? null)
76+
->setIfNotEmpty('body.profile', $options['profile'] ?? null);
7377

7478
if ($size = isset($options['limit']) ? $options['limit'] : $builder->limit) {
7579
$payload->set('body.size', $size);

0 commit comments

Comments
 (0)