如何在弹性搜索中获得没有大小的总记录数

时间:2017-10-27 11:03:22

标签: php elasticsearch

我想从弹性搜索中获取总记录数。 下面是我的代码

 $params = [
            'index' => $this->client->getIndex(),
            'type'  => $this->client->getType(),
            "from" => 0, "size" => 10,
            //"scroll" => "1m",

            'body'  => [
           "query" => [
               "bool" => [
                  "must" => [
                     [
                          "multi_match" => [
                              "fields" => ["prod_name", "prod_seo_name"],
                              "type" => "phrase_prefix",
                              "query" => $query
                          ]
                     ],
                     [
                          "term"=> ["cat_type_id"=>1]
                     ]
                  ]
               ]
            ]
            ],
       ];

执行手动查询会产生400条记录,而弹性搜索会产生10条记录。无论大小如何,我如何获得总记录?

1 个答案:

答案 0 :(得分:0)

我认为应该可以访问:

{{1}}