function extractEndDateFromAlerter($indexName, $indexType) { $endDateParams = ['index' => $indexName, 'type' => $indexType, 'body' => ['size' => 1, 'query' => ['term' => ['host' => '127.0.0.1']], 'sort' => ['endTime' => ['order' => 'desc', 'ignore_unmapped' => 'true']]]]; $client = Elasticsearch\ClientBuilder::create()->build(); $lastAlertTime = $client->search($endDateParams); return $lastAlertTime; }
function getAgentIdData($agentID, $index, $alertType) { $matchesParams = ['index' => $index, 'type' => $alertType, 'body' => ['size' => 10000, 'query' => ['term' => ['agentId.raw' => $agentID]]]]; $client = Elasticsearch\ClientBuilder::create()->build(); $agentIdData = $client->search($matchesParams); return $agentIdData; }
/** * @param $hosts array */ function __construct($hosts) { // create and connect the client $this->client = Elasticsearch\ClientBuilder::create()->setHosts($hosts)->build(); // create and configure the index, if missing $this->createIndex(); }
/** * Establish a database connection and also build several quick * lookup hashes so we can speed up the process. */ public function __construct() { $this->db = new PDO(DB_CONNECT, DB_USER, DB_PASS); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->lookups = new IMS\app\classes\models\Lookups(); $this->hosts = array(ES_HOST . ":" . ES_PORT); $this->clientBuilder = Elasticsearch\ClientBuilder::create(); $this->clientBuilder->setHosts($this->hosts); $this->client = $this->clientBuilder->build(); }
public function __construct($po_db = null) { parent::__construct($po_db); // allow overriding settings from search.conf via constant (usually defined in bootstrap file) // this is useful for multi-instance setups which have the same set of config files for multiple instances if (defined('__CA_ELASTICSEARCH_BASE_URL__') && strlen(__CA_ELASTICSEARCH_BASE_URL__) > 0) { $this->ops_elasticsearch_base_url = __CA_ELASTICSEARCH_BASE_URL__; } else { $this->ops_elasticsearch_base_url = $this->opo_search_config->get('search_elasticsearch_base_url'); } if (defined('__CA_ELASTICSEARCH_INDEX_NAME__') && strlen(__CA_ELASTICSEARCH_INDEX_NAME__) > 0) { $this->ops_elasticsearch_index_name = __CA_ELASTICSEARCH_INDEX_NAME__; } else { $this->ops_elasticsearch_index_name = $this->opo_search_config->get('search_elasticsearch_index_name'); } $this->opo_client = Elasticsearch\ClientBuilder::create()->setHosts([$this->ops_elasticsearch_base_url])->setRetries(2)->build(); }
public function __construct() { $this->client = Elasticsearch\ClientBuilder::create()->setHosts(["localhost:9200"])->setRetries(0)->build(); $this->convert = new ConvertResultController(); }
<?php require_once __DIR__ . '/constants.php'; require_once __DIR__ . '/app_config.php'; require_once __DIR__ . '/routes.inc.php'; require_once SELAMI_BASE_DIR . '/vendor/autoload.php'; $dbConfig = []; $dbConfig['db_name'] = $config['db']['db_name']; $dbConfig['connection_string'] = "mongodb://" . $config['db']['host']; $dbConfig['options'] = $config['db']['options']; $dbClient = new MongoDB\Client($dbConfig['connection_string'], $dbConfig['options']); $indexConfig = []; $indexConfig['db_name'] = $config['index']['index_name']; $indexConfig['hosts'] = $config['index']['hosts']; $indexConfig['options'] = []; $indexClient = Elasticsearch\ClientBuilder::create()->setHosts($indexConfig['hosts'])->build(); $cacheConfig = []; $cacheConfig['host'] = '127.0.0.1'; $cacheConfig['dbIndex'] = 1; $handler = new Redis(); $handler->connect($cacheConfig['host']); $handler->select($cacheConfig['dbIndex']); /* * For Zend\Diactoros * * composer require zendframework/zend-diactoros * * $request = Selami\Http\Bridges\Diactoros\ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); * * */ $request = Selami\Http\Bridges\Diactoros\ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
do { if (isConnected($row["heartbeat"], $row[2])) { $sendquery = "UPDATE t_agents SET status='active' where agent='" . $row["agent"] . "'"; queryOrDie($sendquery); } else { $sendquery = "UPDATE t_agents SET status='inactive' where agent='" . $row["agent"] . "'"; queryOrDie($sendquery); } } while ($row = mysql_fetch_array($order)); } echo '<style>'; echo '.font-icon-color { color: #B4BCC2; }'; echo '.font-icon-color-green { color: #1E9141; }'; echo '</style>'; /* Elasticsearch querys for fraud triangle counts and score */ $client = Elasticsearch\ClientBuilder::create()->build(); $configFile = parse_ini_file("config.ini"); $ESindex = $configFile['es_words_index']; $ESalerterIndex = $configFile['es_alerter_index']; $fraudTriangleTerms = array('r' => 'rationalization', 'o' => 'opportunity', 'p' => 'pressure', 'c' => 'custom'); /* Global data variables */ $urlWords = "http://localhost:9200/logstash-thefraudexplorer-text-*/_stats/docs"; $urlAlerts = "http://localhost:9200/logstash-alerter-*/_stats/docs"; $urlSize = "http://localhost:9200/_all/_stats"; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $urlWords); $resultWords = curl_exec($ch); curl_close($ch); $ch = curl_init();
public function __construct() { $this->elasticclient = Elasticsearch\ClientBuilder::create()->build(); }
<pre> <?php require './vendor/autoload.php'; // Connection ES $es = Elasticsearch\ClientBuilder::create()->setHosts(["shakir:9200"])->build(); /* * Create an index */ //$index = $es->index([ // "index"=>"blogging_index", // "type"=>"blogType", // "body"=>[ // "Title"=>"Test my another Title", // "Body"=>"Hello this for another testing" // ] //]); /* * Get an index */ //$index = $es->get([ // "index" => "blogging_index", // "type" => "blogType", // "id"=>"AVE45jKIKKD7W4VHDzGu" //]); /* * Get an index */ $index = $es->search(["index" => "blogging_index", "type" => "blogType", "body" => ["query" => ["match" => ["Title" => "Title"]]]]); print_r($index); ?> </pre>
public function __construct() { $this->sqlite = new ExcuteSqliteController(); $this->sqlite->openDatabase(); $this->client = Elasticsearch\ClientBuilder::create()->setHosts(["localhost:9200"])->setRetries(0)->build(); }
<?php include "vendor/autoload.php"; $db = Elasticsearch\ClientBuilder::create()->setHosts(['127.0.0.1:9200'])->build(); $subprefeituras_keys = ["AD" => "Subprefeitura de Cidade Ademar", "AF" => "Subprefeitura de Aricanduva", "BT" => "Subprefeitura do Butantã", "CL" => "Subprefeitura do Campo Limpo", "CS" => "Subprefeitura da Capela do Socorro", "CT" => "Subprefeitura de Cidade Tiradentes", "CV" => "Subprefeitura da Casa Verde", "EM" => "Subprefeitura de Ermelino Matarazzo", "FO" => "Subprefeitura da Freguesia/Brasilândia", "GU" => "Subprefeitura de Guaianases", "IP" => "Subprefeitura do Ipiranga", "IQ" => "Subprefeitura de Itaquera", "IT" => "Subprefeitura do Itaim Paulista", "JA" => "Subprefeitura do Jabaquara", "JT" => "Subprefeitura do Jaçanã/Tremembé", "LA" => "Subprefeitura da Lapa", "MB" => "Subprefeitura de M´Boi Mirim", "MG" => "Subprefeitura da Vila Maria/Vila Guilherme", "MO" => "Subprefeitura da Mooca", "MP" => "Subprefeitura de São Miguel Paulista", "NL" => "Não Localizada", "PA" => "Subprefeitura de Parelheiros", "PE" => "Subprefeitura da Penha", "PI" => "Subprefeitura de Pinheiros", "PJ" => "Subprefeitura de Pirituba/Jaraguá", "PR" => "Subprefeitura de Perus", "SA" => "Subprefeitura de Santo Amaro", "SB" => "Subprefeitura de Sapopemba", "SE" => "Subprefeitura da Sé", "SM" => "Subprefeitura de São Mateus", "ST" => "Subprefeitura de Santana/Tucuruvi", "VM" => "Subprefeitura da Vila Mariana", "VP" => "Subprefeitura da Vila Prudente"];