1. Go to this page and download the library: Download nekman/es-pagination 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/ */
nekman / es-pagination example snippets
use Nekman\EsPagination\CursorFactories\EsScrollCursorFactory;
$cursorFactory = new EsScrollCursorFactory(
$elasticsearchClient,
$pageSize = 1000,
$scrollDuration = "1m"
);
$params = [
/*
* Same params as a normal Elasticsearch search operation.
* See Elasticsearch documentation for more information.
*/
];
$cursor = $cursorFactory->hits($params);
foreach ($cursor as $hit) {
echo "Hit {$hit['_id']}";
}
use Nekman\EsPagination\CursorFactories\EsFromCursorFactory;
$cursorFactory = new EsFromCursorFactory(
$elasticsearchClient,
$pageSize = 1000
);
$params = [
/*
* Same params as a normal Elasticsearch search operation.
* See Elasticsearch documentation for more information.
*/
];
$cursor = $cursorFactory->hits($params);
foreach ($cursor as $hit) {
echo "Hit {$hit['_id']}";
}
use Nekman\EsPagination\CursorFactories\EsSearchAfterCursorFactory;
$cursorFactory = new EsSearchAfterCursorFactory(
$elasticsearchClient,
$pageSize = 1000
);
$params = [
/*
* Same params as a normal Elasticsearch search operation.
* See Elasticsearch documentation for more information.
*/
];
$cursor = $cursorFactory->hits($params);
foreach ($cursor as $hit) {
echo "Hit {$hit['_id']}";
}
use \Nekman\EsPagination\CursorFactories\EsPitCursorFactory;
$cursorFactory = /* Create cursor factory, see above */;
$pitCursorFactory = new EsPitCursorFactory(
$cursorFactory,
$elasticsearchFactory,
$pitKeepAlive = "1m"
);
$params = [
/*
* Same params as a normal Elasticsearch search operation.
* See Elasticsearch documentation for more information.
*/
];
$cursor = $cursorFactory->hits($params);
foreach ($cursor as $hit) {
echo "Hit {$hit['_id']}";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.