PHP code example of salamtam / elasticsearch-loop-php
1. Go to this page and download the library: Download salamtam/elasticsearch-loop-php 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/ */
salamtam / elasticsearch-loop-php example snippets
use ElasticsearchLoopPHP\ElasticsearchLoop;
/* set connection elasticsearch */
$url = "localhost:9200";
/* set index name and type */
$params = [
'index' => 'index_name',
'type' => 'index_type',
'body' => [
'query' => [
'match_all' => []
]
]
];
/* callback function */
$callback = function($response) {
foreach ($response['hits']['hits'] as $item) {
print_r($item);
}
};
/* set query with url */
$client = new ElasticsearchLoop($url);
$client->getElasticsearch($params, $callback);
use ElasticsearchLoopPHP\ElasticsearchLoop;
/* set connection elasticsearch */
$user = "root";
$pass = "";
$host = "localhost";
$port = "9200";
/* set index name and type */
$params = [
'index' => 'index_name',
'type' => 'index_type',
'body' => [
'query' => [
'match_all' => []
]
]
];
/* callback function */
$callback = function($response) {
foreach ($response['hits']['hits'] as $item) {
print_r($item);
}
};
/* set query with host, user, pass and port */
$client = new ElasticsearchLoop($host, $user, $pass, $port);
$client->getElasticsearch($params, $callback);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.