Elasticsearch PHP中的分页

时间:2017-10-27 07:25:42

标签: php elasticsearch

我在Elasticsearch中有一个返回400条记录的数组:

$result = $search->search($keyword);
echo "<pre>"; print_r($result); exit;

我正在运行$results的foreach循环来显示。如何添加Elasticsearch的分页?

下面是搜索代码:

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

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

在BD中查询返回400条记录,但弹性搜索在我添加大小时给出100。如何滚动到另一页?

我的URl:http://example.com/ppm2.0/search.html?q=samsung

0 个答案:

没有答案