小编Hul*_*ula的帖子

如何进行分页弹性搜索?

我是弹性搜索的新手。

我尝试制作真正的应用程序。我正在使用 elasticsearch-php
https://github.com/elastic/elasticsearch-php

我不知道要分页。

我的代码:

<?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" …
Run Code Online (Sandbox Code Playgroud)

php elasticsearch

4
推荐指数
1
解决办法
4019
查看次数

标签 统计

elasticsearch ×1

php ×1