I am new with elasticsearch.
I try to make real app. I am using elasticsearch-php
https://github.com/elastic/elasticsearch-php
I don't know to make pagination.
my code :
<?php
require_once 'app/init.php';
if(isset ($_GET['q'])) {
$q = $_GET['q'];
$query = $es->search([
'index' => 'user',
'type' => 'profile',
'body' => [
'query' => [
'bool' => [
'should' => [
'match' => ['bio' => $q]
]
]
]
]
]);
if ($query['hits']['total'] >=1) {
$results= $query['hits']['hits'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Search | ES</title>
</head>
<body>
<form class="" action="index.php" method="get" autocomplete="off">
<label for="">
Search
<input type="text" name="q">
</label>
<input type="submit" value="search">
</form>
<?php
if (isset($results)) {
foreach ($results as $r) {
?>
<div class="result">
<?php echo $r['_source']['bio']; ?>
</div>
<?php
}
}
?>
</body>
</html>
and how to make pagination like this :