PHP code example of amorpro / selastic
1. Go to this page and download the library: Download amorpro/selastic library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amorpro / selastic example snippets
$client = new \Selastic\Client('http://yourelasticnode.com');
// Not requared, by default will be used '_all'
$client->useIndex('analytics');
// Simple string query
$result = $client->search('user:12');
// Array query
$result = $client->search(['user' => 12]);
// Json query
$result = $client->search('{ "user" : 12 }');
// Array aggregation query
$result = $client->search([ 'query' => [...], 'aggs' => [...] ]);
// Json aggregation query
$result = $client->search('{"query" : {...}, "aggs" => {...}}');