Skip to content

Commit

Permalink
fixed a bug regarding to orWhere
Browse files Browse the repository at this point in the history
  • Loading branch information
ShisunXia committed Nov 13, 2018
1 parent c7c1aa2 commit ceb1318
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/LaravelElasticsearchQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,14 @@ public function where($column, $operator = null, $value = null, $or = false, $bo
break;
case '!=':
if($or) {
$builder = new LaravelElasticsearchQueryBuilder($this->model);
$builder->where($column, '!=', $value);
if(isset($this->query['bool']['should']['bool']) && $value !== null) {
$this->query['bool']['should']['bool']['must_not'][] = [(is_array($value) ? 'terms' : 'term') => [$column => $value]];
} else if(isset($this->query['bool']['should']) && $value === null) {
$this->query['bool']['should'][] = ['exists' => ['field' => $column]];
if($value === null) {
$this->query['bool']['should'][] = ['exists' => [
'field' => $column
]];
} else {
if($value === null) {
$this->query['bool']['should'][] = ['exists' => [
'field' => $column
]];
} else {
$this->query['bool']['should']['bool'] = ['must_not' => [
[(is_array($value) ? 'terms' : 'term') => [$column => $value]]
]];
}
$this->query['bool']['should'][] = ['bool' => ['must_not' => [
[(is_array($value) ? 'terms' : 'term') => [$column => $value]]
]]];
}
} else {
if($value === null) {
Expand Down

0 comments on commit ceb1318

Please sign in to comment.