Skip to content

Commit 3768963

Browse files
committed
rawSearch has option to return results as is (unsanitized)
1 parent d713d57 commit 3768963

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/DSL/Bridge.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function processClosePit($id): bool
134134
/**
135135
* @throws Exception
136136
*/
137-
public function processSearchRaw($bodyParams): Results
137+
public function processSearchRaw($bodyParams, $returnRaw): Results
138138
{
139139
$params = [
140140
'index' => $this->index,
@@ -143,6 +143,9 @@ public function processSearchRaw($bodyParams): Results
143143
];
144144
try {
145145
$process = $this->client->search($params);
146+
if ($returnRaw) {
147+
return $this->_return($process->asArray(), [], $params, $this->_queryTag(__FUNCTION__));
148+
}
146149

147150
return $this->_sanitizeSearchResponse($process, $params, $this->_queryTag(__FUNCTION__));
148151
} catch (Exception $e) {
@@ -819,7 +822,7 @@ private function _avgAggregate($wheres, $options, $columns): Results
819822
$process = $this->client->search($params);
820823

821824
return $this->_sanitizeAggsResponse($process, $params, $this->_queryTag(__FUNCTION__));
822-
825+
823826
} catch (Exception $e) {
824827
$this->throwError($e, $params, $this->_queryTag(__FUNCTION__));
825828
}

src/Eloquent/Docs/ModelDocs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
* @method $this chunk(string $column, Callable $callback, string $keepAlive = '5m')
5252
* @method $this chunkById(string $count, callable $callback, $column = '_id', $alias = null, $keepAlive = '5m')
5353
* @method $this queryNested(string $column, Callable $callback)
54-
* @method $this rawSearch(array $bodyParams)
54+
* @method $this rawSearch(array $bodyParams, bool $returnRaw = false)
5555
* @method $this rawAggregation(array $bodyParams)
5656
*
5757
* @method $this highlight(array $fields = [], string|array $preTag = '<em>', string|array $postTag = '</em>', $globalOptions = [])

src/Query/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,9 +1317,9 @@ public function createIndex()
13171317
return false;
13181318
}
13191319

1320-
public function rawSearch(array $bodyParams)
1320+
public function rawSearch(array $bodyParams, $returnRaw = false)
13211321
{
1322-
$find = $this->connection->searchRaw($bodyParams);
1322+
$find = $this->connection->searchRaw($bodyParams, $returnRaw);
13231323
$data = $find->data;
13241324

13251325
return new Collection($data);

0 commit comments

Comments
 (0)