Elasticsearch PHP客户端错误 - 500无法处理此请求

时间:2016-12-25 11:46:22

标签: php html elasticsearch

我正在做this tutorial said。基本上我已经使用Composer添加了Elasticsearch PHP客户端。我的Elasticsearch在localhost:32773上的Docker上运行。

这是我的index.php代码。我想要做的是在Elasticsearch中搜索我的文档并显示就像在本教程中一样。

<?php
use Elasticsearch\ClientBuilder;
require 'vendor/autoload.php';

$hosts = [
      // Just Domain
    'http://192.168.1.101:32773',
    'http://127.0.0.1:32773'  // SSL to IP + Port
];
$clientBuilder = ClientBuilder::create();   // Instantiate a new ClientBuilder
$clientBuilder->setHosts($hosts);           // Set the hosts
$client = $clientBuilder->build(); 
if(isset($_GET['q'])) {
    $q=$_GET['q'];
    $query=$es->search([
        'result'=> [
            'query'=>[
            'bool' => [
            'should' => [
            'match' => ['year' => $q]],
            'match' => ['body' => $q]
            ]
            ]
            ]
        ]);
    echo'<pre>',print_r($results),'</pre>';
    if($query['hits'] ['total'] >=1) {
        $results=$query['hits'] ['hits'];
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title> Search | ES</title>
    <link rel="stylesheet" href="css/main.css">
</head>

<body>
<form action="index.php" method="get" autocomplete="off">
    <label>
        Search for something
        <input type="text" name="q">
    </label>
    <input type="submit" value="Search">
</form>
</body>
</html>

我没有得到任何输出。当我按搜索时,它说

  

localhost页面无效

     

localhost目前无法处理此请求。

     

HTTP ERROR 500

0 个答案:

没有答案