本文整理汇总了PHP中CSearch::loadIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP CSearch::loadIndex方法的具体用法?PHP CSearch::loadIndex怎么用?PHP CSearch::loadIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSearch
的用法示例。
在下文中一共展示了CSearch::loadIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CSearchLog
// Recherche par aggreg pour les logs
if ($date || $user_id) {
$client_index = new CSearchLog();
$client_index->createClient();
$client_index->loadIndex($client_index->loadNameIndex());
$date = CMbDT::format($date, "%Y/%m/%d");
$words .= "date:[" . $date . " TO " . "{$date}] user_id:(" . $user_id . ")";
$agregation = array();
$tabActive = "";
if (!$types) {
$types = $client_index->loadContextes();
}
} else {
$client_index = new CSearch();
$client_index->createClient();
$client_index->loadIndex();
$words .= " object_ref_class:" . $object_ref_class . " " . "object_ref_id:" . $object_ref_id;
$results = $client_index->queryByType($words, null, $types);
$agregation = $results->getAggregation("ref_type");
$tabActive = $agregation["buckets"][0]["key"];
}
try {
$results = $client_index->queryByType($words, $client_index->_index->getName(), $types);
$agregation = $results->getAggregation("ref_type");
$tabActive = $agregation["buckets"][0]["key"];
} catch (Exception $e) {
CAppUI::displayAjaxMsg("Problème à la récupération des données", UI_MSG_ERROR);
}
$smarty = new CSmartyDP();
$smarty->assign("agregation", $agregation["buckets"]);
$smarty->assign("date", $date);
示例2: loadCartoInfos
/**
* Method to load cartos infos
*
* @param CSearch $c_search the csearch
* @param array $aggreg the aggreg
*
* @return array
*/
function loadCartoInfos($c_search, $aggreg)
{
$result = array();
$search = new CSearchIndexing();
// récupération de l'index, cluster
$index = $c_search->loadIndex();
$cluster = $c_search->_client->getCluster();
// statistiques du cluster
$path = '_cluster/stats';
$response = $c_search->_client->request($path, Request::GET);
$data = $response->getData();
$result['stats']['cluster']["nbIndex"] = $data["indices"]["count"];
$result['stats']['cluster']["nbDocsTotal"] = $data["indices"]["docs"]["count"];
// récupération du mapping et du name_index
$result['mapping'] = $index->getMapping();
$result['mappingjson'] = json_encode($result['mapping']);
$result['name_index'] = $index->getName();
// récupération de la taille totale des indexes et de statistiques
$stats = $index->getStats()->getData();
$result['size'] = CMbString::toDecaBinary($stats["_all"]["primaries"]["store"]["size_in_bytes"]);
// récupération de l'état des shards
$result['stats']['shards']["total"] = $stats["_shards"]['total'];
$result['stats']['shards']["successful"] = $stats["_shards"]['successful'];
$result['stats']['shards']["failed"] = $stats["_shards"]['failed'];
// récupération de statistiques
$name = CAppUI::conf("search index_name");
$result['stats']["search"]['total'] = $stats["indices"][$name]["primaries"]["search"]["query_total"];
$result['stats']["search"]['average_time'] = $stats["indices"][$name]["primaries"]["search"]["query_time_in_millis"];
// récupération du nombre de docs "indexés", "à indexer" et récupération des types d'éléments restant à indexer.
$result['nbDocs_indexed'] = $index->count();
$result['nbdocs_to_index'] = $search->countList();
$order = "`object_class`, COUNT(`object_class`) AS `total`";
$result['nbdocs_to_index_by_type'] = $search->countMultipleList(null, null, "object_class", null, $order);
// récupération du statut de la connexion et du cluster
$result['status'] = $cluster->getHealth()->getStatus();
$result['connexion'] = $c_search->_client->hasConnection();
// récupération des données de l'agregation
$aggreg = $aggreg->getAggregation("ref_type");
$result["aggregation"] = $aggreg["buckets"];
return $result;
}