Ejemplo n.º 1
0
 /**
  * Construct the datum for logging
  *
  * @param array   $names_types Types
  * @param string  $contexte    Contexte
  * @param integer $user_id     User who have make the search
  * @param string  $words       the words of the search
  * @param bool    $aggregation aggregation or not
  *
  * @return void
  */
 function log($names_types, $contexte, $user_id, $words, $aggregation)
 {
     if (!$names_types) {
         $names_types = array();
     }
     $document = array();
     $document['aggregation'] = $aggregation;
     $document['body'] = CMbString::normalizeUtf8($words);
     $document['user_id'] = $user_id;
     $document['types'] = implode(" ", $names_types);
     $document['date'] = CMbDT::format(null, "%Y/%m/%d");
     $this->createClient();
     $index = $this->loadIndex($this->loadNameIndex());
     $type = $index->getType($contexte);
     $log = $type->createDocument('', $document);
     $type->addDocument($log);
     $type->getIndex()->refresh();
 }
Ejemplo n.º 2
0
$authors = array();
$author_ids = array();
$patients = array();
try {
    $date = $client_index->constructWordsWithDate($_date, $_min_date, $_max_date);
    $results_query = $client_index->searchQueryString($words, $start, 30, $names_types, $aggregate, $sejour_id, $specific_user, null, $date, $fuzzy_search);
    $results = $results_query->getResults();
    $time = $results_query->getTotalTime();
    $nbresult = $results_query->getTotalHits();
    // traitement des résultats
    $patient_ids = array();
    foreach ($results as $result) {
        $var = $result->getHit();
        $author_ids[] = $var["_source"]["author_id"];
        $patient_ids[] = $var["_source"]["patient_id"];
        $var["_source"]["body"] = CMbString::normalizeUtf8($var["_source"]["body"]);
        $array_results[] = $var;
        // Traitement des highlights
        $highlights = $result->getHighlights();
        if (count($highlights) != 0) {
            $array_highlights[] = mb_convert_encoding(implode(" [...] ", $highlights['body']), "WINDOWS-1252", "UTF-8");
        } else {
            $array_highlights[] = "";
        }
    }
    // traitement des auteurs
    foreach ($author_ids as $author) {
        $authors[$author] = CMbObject::loadFromGuid("CMediusers-{$author}");
        $authors[$author]->loadRefFunction();
    }
    // traitement des patients
Ejemplo n.º 3
0
 /**
  * Method to normalize text
  *
  * @param String $text The text to normalize
  *
  * @return String
  */
 function normalizeEncoding($text)
 {
     $text = mb_convert_encoding($text, "UTF-8", "Windows-1252");
     return CMbString::normalizeUtf8($text);
 }