esbuilder提供一个Elasticsearch的查询构造器,像使用Laravel一样。 安装 composer require 'yuancode/esbuilder' 使用 创建一个es客户 use Elasticsearch \ ClientBuilder ; use Yuancode \ Es \ Builder ; $ client = ClientBuilder :: create ()-> setHosts ([ 'localhost:9200' ])-> build (); $ query = Builder :: client ( $ client ); 设置索引 Builder :: client ( $ client )-> index ( 'testindex' ); 插入 $ row = [ 'name' => '张三' , 'age'