Skip to content

Commit e545cde

Browse files
authored
Merge pull request #217 from hkulekci/readme-update
raw search sample fixed
2 parents 6558df4 + f51db58 commit e545cde

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ $results = Product::search('zonga', function($client, $body) {
215215
$body->addAggregation($minPriceAggregation);
216216
$body->addAggregation($brandTermAggregation);
217217

218-
return $client->search(['index' => 'products', 'body' => $body->toArray()]);
218+
return $client->search(['index' => 'products', 'body' => $body->toArray()])->asArray();
219219
})->raw();
220220
```
221221

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"laravel/legacy-factories": "^1.0",
2727
"nunomaduro/larastan": "~0.6",
2828
"orchestra/testbench": "^6.18",
29+
"php-http/guzzle7-adapter": "^1.0",
2930
"phpunit/phpunit": "~9.4.0"
3031
},
3132
"autoload-dev": {

tests/Feature/ElasticSearchEngineTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ public function test_pass_empty_response(): void
2222
Artisan::call('scout:import');
2323

2424
$results = Product::search('Quia', static function ($client, $body) {
25-
return $client->search(['index' => 'products', 'body' => $body->toArray()]);
25+
return $client->search(['index' => 'products', 'body' => $body->toArray()])->asArray();
2626
})->raw();
27+
28+
$this->assertIsArray($results);
2729
$this->assertEmpty($results['hits']['hits']);
2830
}
2931

@@ -39,9 +41,10 @@ public function test_pass_with_response(): void
3941
Artisan::call('scout:import');
4042

4143
$results = Product::search('iphone', static function ($client, $body) {
42-
return $client->search(['index' => 'products', 'body' => $body->toArray()]);
44+
return $client->search(['index' => 'products', 'body' => $body->toArray()])->asArray();
4345
})->raw();
4446

47+
$this->assertIsArray($results);
4548
$this->assertNotEmpty($results['hits']['hits']);
4649
}
4750
}

0 commit comments

Comments
 (0)