Skip to content

Commit

Permalink
Merge pull request #217 from hkulekci/readme-update
Browse files Browse the repository at this point in the history
raw search sample fixed
  • Loading branch information
matchish authored Sep 5, 2022
2 parents 6558df4 + f51db58 commit e545cde
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ $results = Product::search('zonga', function($client, $body) {
$body->addAggregation($minPriceAggregation);
$body->addAggregation($brandTermAggregation);

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

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"laravel/legacy-factories": "^1.0",
"nunomaduro/larastan": "~0.6",
"orchestra/testbench": "^6.18",
"php-http/guzzle7-adapter": "^1.0",
"phpunit/phpunit": "~9.4.0"
},
"autoload-dev": {
Expand Down
7 changes: 5 additions & 2 deletions tests/Feature/ElasticSearchEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public function test_pass_empty_response(): void
Artisan::call('scout:import');

$results = Product::search('Quia', static function ($client, $body) {
return $client->search(['index' => 'products', 'body' => $body->toArray()]);
return $client->search(['index' => 'products', 'body' => $body->toArray()])->asArray();
})->raw();

$this->assertIsArray($results);
$this->assertEmpty($results['hits']['hits']);
}

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

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

$this->assertIsArray($results);
$this->assertNotEmpty($results['hits']['hits']);
}
}

0 comments on commit e545cde

Please sign in to comment.