ElasticsearchClient.php 377 B

12345678910111213141516171819202122
  1. <?php
  2. namespace App\Foundation;
  3. use Elasticsearch\Client;
  4. use Elasticsearch\ClientBuilder;
  5. class ElasticsearchClient
  6. {
  7. protected $hosts = [];
  8. public function __construct(array $hosts)
  9. {
  10. $this->hosts = $hosts;
  11. }
  12. public function client(): Client
  13. {
  14. return ClientBuilder::create()->setHosts($this->hosts)
  15. ->build();
  16. }
  17. }