elasticsearch,Php,Mysql,elasticsearch" /> elasticsearch,Php,Mysql,elasticsearch" />

无法在弹性搜索php+;mysql

无法在弹性搜索php+;mysql,php,mysql,elasticsearch,Php,Mysql,elasticsearch,我正在PHP+Mysql中集成弹性搜索 据我所知,弹性搜索默认只返回10条记录 下面是我的搜索查询 $params = [ 'index' => $this->client->getIndex(), 'type' => $this->client->getType(), //"scroll" => "1m", 'body' => [

我正在PHP+Mysql中集成弹性搜索

据我所知,弹性搜索默认只返回10条记录

下面是我的搜索查询

 $params = [
            'index' => $this->client->getIndex(),
            'type'  => $this->client->getType(),

            //"scroll" => "1m",

            'body'  => [
            "query" => [
               "bool" => [
                  "must" => [
                     [
                          "multi_match" => [
                              "fields" => ["prod_name", "prod_seo_name"],
                              "type" => "phrase_prefix",
                              "query" => 'samsung'
                          ]
                     ],
                     [
                          "term"=> ["cat_type_id"=>1]
                     ]
                  ]
               ]
            ]
            ],
       ]; 
 $query  = $client->search($params);


    //return  array($this->extractResult($query),$this->extractResult($query1));
    return  $this->extractResult($query);

上面的查询在mysql中返回了2000多条记录,但弹性搜索给出了10条。我可以把'大小高达1000'在弹性搜索,但这不会满足要求。如何获取弹性搜索中的总记录数。我想获取php分页的计数。

我不知道php Elasticsearch库是如何工作的,但是Elasticsearch返回一个json对象,其中字段
hits
,它是一个包含字段
total
hits
的对象,其中内部的
hits
是结果数组,
total
是匹配文档的总数。我不知道php Elasticsearch库是如何工作的,但是Elasticsearch返回一个json对象,其中字段
hits
,这是一个包含字段
total
hits
的对象,其中内部的
hits
是结果数组,
total
是匹配文档的总数。