[英]How to get the number of documents in Elastic Search with Elastic Search php
我正在使用Elastic Search php客戶端( 此客戶端)。 我正在嘗試獲取一種類型中文檔的總數,但無法弄清楚該怎么做。 任何幫助將不勝感激。
這是我嘗試過的:
$params['index'] = $index_name;
$params['type'] = 'applicant';
$applicants_count = Es::count($params)["count"];
但這似乎總是返回0。
找到了答案。 發生這種情況是因為我試圖在測試中得到結果,該測試要求在對文檔建立索引后立即將count計數。 我在之間添加了refresh
命令( Es::indices()->refresh(array("index" => $params["index"]));
)),該問題得以解決:
$params['index'] = $index_name;
$params['type'] = 'applicant';
Es::indices()->refresh(array("index" => $params["index"]));
$applicants_count = Es::count($params)["count"];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.