コード例 #1
0
// 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
0
 /**
  * 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;
 }