thinkphp6 Elasticsearch使用及基本查询

1、安装扩展

composer require elasticsearch/elasticsearch

2、连接ES客户端


/*
User : Administrator
Date : 2020/8/31
Time : 14:36
*/

use Elasticsearch\ClientBuilder;

class EsModel
{
   
	protected function getEsClient()
    {
   
        $client = ClientBuilder::create()->setHosts([$this->getEsConfig()])
            ->setConnectionPool('\Elasticsearch\ConnectionPool\SimpleConnectionPool', [])
            ->setRetries(10)->build();
        return $client;
    }

    protected function getEsConfig()
    {
   
        $config = [
            'host'      => '127.0.0.1',
            'port'      => '8200',
            'scheme'    

你可能感兴趣的:(elasticsearch,php)