/**
  * function to call in static way in class.
  *
  * @param CMbObject $object the object you want to handled
  * @param string    $type   [optionnal] the action to do
  *
  * @return bool
  */
 static function requesthandler(CMbObject $object, $type = null)
 {
     self::checkHandled($object);
     if ($object instanceof CCompteRendu && !$object->object_id) {
         // si c'est un modèle de document
         return false;
     }
     if ($object instanceof CFile && !in_array($object->object_class, array('CSejour', 'CConsultation', 'CConsultAnesth', 'COperation'))) {
         return false;
     }
     if ($object instanceof CPrescriptionLineMedicament && $object->loadRefPrescription()->loadRefObject() instanceof CDossierMedical) {
         return false;
     }
     if (!$type) {
         if (!$object->_ref_current_log) {
             $type = "create";
         } else {
             $type = $object->_ref_current_log->type;
         }
     }
     $search_indexing = new CSearchIndexing();
     $search_indexing->type = $type;
     $search_indexing->date = CMbDT::dateTime();
     $search_indexing->object_class = $object->_class;
     $search_indexing->object_id = $object->_id ? $object->_id : $object->_save_id;
     // save_id dans le cas du delete
     $group = self::loadRefGroup($object);
     if (!CAppUI::conf("search active_handler active_handler_search", $group)) {
         return false;
     }
     $search_indexing->store();
     return true;
 }
Example #2
0
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @link     http://www.mediboard.org
 */
CCanDo::checkAdmin();
$table = CValue::get("table");
$mapping = CValue::get("mapping");
$log = CValue::get("log", "");
$names_types = CValue::get("names_types");
// les catégories de documents cochées.
$error = "";
// Remplissage de la table temporaire avec le bouton "Remplir table temporaire"
if ($table) {
    $ds = CSQLDataSource::get("std");
    $search_indexing = new CSearchIndexing();
    foreach ($names_types as $name_type) {
        $queries = $search_indexing->firstIndexingStore($name_type);
        foreach ($queries as $query) {
            $ds->exec($query);
        }
    }
    CAppUI::displayAjaxMsg("l'opération en base s'est déroulée avec succès ", UI_MSG_OK);
}
// Création du mapping pour l'index principal
try {
    if ($mapping) {
        $client_index = new CSearch();
        //create a client
        $client_index->createClient();
        $index = $client_index->getIndex(CAppUI::conf("db std dbname"))->exists();
Example #3
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;
 }