Skip to content

Commit ceb1318

Browse files
committed
fixed a bug regarding to orWhere
1 parent c7c1aa2 commit ceb1318

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/LaravelElasticsearchQueryBuilder.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,22 +202,14 @@ public function where($column, $operator = null, $value = null, $or = false, $bo
202202
break;
203203
case '!=':
204204
if($or) {
205-
$builder = new LaravelElasticsearchQueryBuilder($this->model);
206-
$builder->where($column, '!=', $value);
207-
if(isset($this->query['bool']['should']['bool']) && $value !== null) {
208-
$this->query['bool']['should']['bool']['must_not'][] = [(is_array($value) ? 'terms' : 'term') => [$column => $value]];
209-
} else if(isset($this->query['bool']['should']) && $value === null) {
210-
$this->query['bool']['should'][] = ['exists' => ['field' => $column]];
205+
if($value === null) {
206+
$this->query['bool']['should'][] = ['exists' => [
207+
'field' => $column
208+
]];
211209
} else {
212-
if($value === null) {
213-
$this->query['bool']['should'][] = ['exists' => [
214-
'field' => $column
215-
]];
216-
} else {
217-
$this->query['bool']['should']['bool'] = ['must_not' => [
218-
[(is_array($value) ? 'terms' : 'term') => [$column => $value]]
219-
]];
220-
}
210+
$this->query['bool']['should'][] = ['bool' => ['must_not' => [
211+
[(is_array($value) ? 'terms' : 'term') => [$column => $value]]
212+
]]];
221213
}
222214
} else {
223215
if($value === null) {

0 commit comments

Comments
 (0)