我是弹性搜索的新手。
我尝试制作真正的应用程序。我正在使用 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)