Skip to content

Commit

Permalink
rawSearch has option to return results as is (unsanitized)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdphilip committed Aug 17, 2024
1 parent 2d3fedf commit f289330
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/DSL/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function processClosePit($id): bool
/**
* @throws Exception
*/
public function processSearchRaw($bodyParams): Results
public function processSearchRaw($bodyParams, $returnRaw): Results
{
$params = [
'index' => $this->index,
Expand All @@ -142,6 +142,9 @@ public function processSearchRaw($bodyParams): Results
];
try {
$process = $this->client->search($params);
if ($returnRaw) {
return $this->_return($process, [], $params, $this->_queryTag(__FUNCTION__));
}

return $this->_sanitizeSearchResponse($process, $params, $this->_queryTag(__FUNCTION__));
} catch (Exception $e) {
Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/Docs/ModelDocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* @method $this chunk(string $column, Callable $callback, string $keepAlive = '5m')
* @method $this chunkById(string $count, callable $callback, $column = '_id', $alias = null, $keepAlive = '5m')
* @method $this queryNested(string $column, Callable $callback)
* @method $this rawSearch(array $bodyParams)
* @method $this rawSearch(array $bodyParams, bool $returnRaw = false)
* @method $this rawAggregation(array $bodyParams)
*
* @method $this highlight(array $fields = [], string|array $preTag = '<em>', string|array $postTag = '</em>', $globalOptions = [])
Expand Down
4 changes: 2 additions & 2 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1316,9 +1316,9 @@ public function createIndex()
return false;
}

public function rawSearch(array $bodyParams)
public function rawSearch(array $bodyParams, $returnRaw = false)
{
$find = $this->connection->searchRaw($bodyParams);
$find = $this->connection->searchRaw($bodyParams, $returnRaw);
$data = $find->data;

return new Collection($data);
Expand Down

0 comments on commit f289330

Please sign in to comment.