コード例 #1
0
ファイル: Helpers.php プロジェクト: ekandreas/docker-bedrock
 public static function kill()
 {
     $mysql_name = env('container') . '_mysql';
     $mysql = new Mysql($mysql_name);
     $mysql->kill();
     $elastic_name = env('container') . '_elastic';
     $elastic = new Elasticsearch($elastic_name);
     $elastic->kill();
     $web_name = basename(self::getProjectDir());
     $web_name .= '_web';
     $web = new Web($web_name);
     $web->kill();
 }
コード例 #2
0
 public static function all()
 {
     $size_query = ['filter' => ['exists' => ['field' => 'lat']]];
     $points_size = Elasticsearch::countHits($size_query, 'resource');
     $query = ['size' => 2000, 'filter' => ['exists' => ['field' => 'lat']]];
     $points = Elasticsearch::allHits($query, 'resource');
     return $points;
 }
コード例 #3
0
ファイル: index.php プロジェクト: cweiske/phinde
    if (strlen($params)) {
        return $baseLink . '&' . $params;
    }
    return $baseLink;
}
if (preg_match('#site:([^ ]*)#', $query, $matches)) {
    $site = $matches[1];
    $cleanQuery = trim(str_replace('site:' . $site, '', $query));
    $site = Helper::noSchema($site);
    $urlNoSite = buildLink('?q=' . urlencode($cleanQuery), $filters, null, null);
} else {
    $cleanQuery = $query;
    $urlNoSite = null;
}
$timeBegin = microtime(true);
$es = new Elasticsearch($GLOBALS['phinde']['elasticsearch']);
$res = $es->search($cleanQuery, $filters, $site, $page, $perPage, $sort);
$timeEnd = microtime(true);
$pager = new Html_Pager($res->hits->total, $perPage, $page + 1, $baseLink);
foreach ($res->hits->hits as &$hit) {
    $doc = $hit->_source;
    if (!isset($doc->title) || $doc->title == '') {
        $doc->title = '(no title)';
        $doc->htmlTitle = '(no title)';
    }
    if (isset($hit->highlight->title[0])) {
        $doc->htmlTitle = $hit->highlight->title[0];
    } else {
        $doc->htmlTitle = htmlspecialchars($doc->title);
    }
    if (isset($hit->highlight->text[0])) {
コード例 #4
0
ファイル: status.php プロジェクト: cweiske/phinde
<?php

namespace phinde;

require 'www-header.php';
$es = new Elasticsearch($GLOBALS['phinde']['elasticsearch']);
$esStatus = $es->getIndexStatus();
$queue = new Queue();
$gearStatus = $queue->getServerStatus();
/**
 * @link http://jeffreysambells.com/2012/10/25/human-readable-filesize-php
 */
function human_filesize($bytes, $decimals = 2)
{
    $size = array('B', 'kiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB');
    $factor = floor((strlen($bytes) - 1) / 3);
    return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor];
}
$esStatus['size_human'] = human_filesize($esStatus['size']);
$esStatus['documents_human'] = number_format($esStatus['documents'], 0, '.', ' ');
render('status', array('esStatus' => $esStatus, 'gearStatus' => $gearStatus));
コード例 #5
0
 public function __construct($indexName, $params = [])
 {
     parent::__construct();
     $this->name = $indexName;
     $this->params = new ParamBuilder($this, []);
 }