Skip to content

Commit 20761d2

Browse files
committed
Move to permanent branch for Laravel 9 and ES 7.x
1 parent b600ec2 commit 20761d2

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/DSL/Bridge.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ public function processFind($wheres, $options, $columns): Results
9898
public function processSearch($searchParams, $searchOptions, $wheres, $opts, $fields, $cols)
9999
{
100100
$params = $this->buildSearchParams($this->index, $searchParams, $searchOptions, $wheres, $opts, $fields, $cols);
101-
102-
// dd($params);
103101

104102
return $this->_returnSearch($params, __FUNCTION__);
105103

@@ -116,7 +114,8 @@ protected function _returnSearch($params, $source)
116114
return $this->_sanitizeSearchResponse($process, $params, $this->_queryTag($source));
117115
} catch (Exception $e) {
118116

119-
return $this->_returnError($e->getMessage(), $e->getCode(), $params, $this->_queryTag($source));
117+
$error = $this->_returnError($e->getMessage(), $e->getCode(), $params, $this->_queryTag(__FUNCTION__));
118+
throw new Exception($error->errorMessage);
120119
}
121120
}
122121

@@ -127,10 +126,9 @@ public function processDistinct($column, $wheres): Results
127126
if (is_array($column)) {
128127
$col = $column[0];
129128
}
130-
131-
129+
$params = $this->buildParams($this->index, $wheres);
132130
try {
133-
$params = $this->buildParams($this->index, $wheres);
131+
134132
$params['body']['aggs']['distinct_'.$col]['terms'] = [
135133
'field' => $col,
136134
'size' => $this->maxSize,
@@ -146,7 +144,8 @@ public function processDistinct($column, $wheres): Results
146144
return $this->_return($data, $process, $params, $this->_queryTag(__FUNCTION__));
147145
} catch (Exception $e) {
148146

149-
return $this->_returnError($e->getMessage(), $e->getCode(), $params, $this->_queryTag(__FUNCTION__));
147+
$error = $this->_returnError($e->getMessage(), $e->getCode(), $params, $this->_queryTag(__FUNCTION__));
148+
throw new Exception($error->errorMessage);
150149
}
151150

152151

@@ -195,7 +194,9 @@ public function processSave($data, $refresh): Results
195194

196195
return $this->_return($savedData, $response, $params, $this->_queryTag(__FUNCTION__));
197196
} catch (Exception $e) {
198-
return $this->_returnError($e->getMessage(), $e->getCode(), $params, $this->_queryTag(__FUNCTION__));
197+
$error = $this->_returnError($e->getMessage(), $e->getCode(), $params, $this->_queryTag(__FUNCTION__));
198+
throw new Exception($error->errorMessage);
199+
199200
}
200201

201202

@@ -312,7 +313,8 @@ public function processDeleteAll($wheres, $options = []): Results
312313

313314
return $this->_return($response['deleteCount'], $response, $params, $this->_queryTag(__FUNCTION__));
314315
} catch (Exception $e) {
315-
return $this->_returnError($e->getMessage(), $e->getCode(), $params, $this->_queryTag(__FUNCTION__));
316+
$error = $this->_returnError($e->getMessage(), $e->getCode(), [], $this->_queryTag(__FUNCTION__));
317+
throw new Exception($error->errorMessage);
316318
}
317319

318320
}

src/DSL/QueryBuilder.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ public function buildSearchParams($index, $searchQuery, $searchOptions, $wheres
8181
}
8282

8383
/**
84+
* @param $index
85+
* @param $wheres
86+
* @param $options
87+
* @param $columns
88+
* @param $_id
89+
*
90+
* @return array
8491
* @throws Exception
8592
*/
8693
public function buildParams($index, $wheres, $options = [], $columns = [], $_id = null): array

0 commit comments

Comments
 (0)