Php 致命错误:未捕获的Elasticsearch\Common\Exceptions\BadRequest400Exception
所以我用的是elasticsearch 我有以下代码:Php 致命错误:未捕获的Elasticsearch\Common\Exceptions\BadRequest400Exception,php,elasticsearch,runtime-error,fatal-error,Php,elasticsearch,Runtime Error,Fatal Error,所以我用的是elasticsearch 我有以下代码: <?php error_reporting(E_ALL);ini_set('display_errors', 1); require 'vendor/autoload.php'; use Elasticsearch\ClientBuilder; $hosts = [ 'http://localhost:80', // SSL to localhost ]; $client
<?php
error_reporting(E_ALL);ini_set('display_errors', 1);
require 'vendor/autoload.php';
use Elasticsearch\ClientBuilder;
$hosts = [
'http://localhost:80', // SSL to localhost
];
$clientBuilder = ClientBuilder::create(); // Instantiate a new ClientBuilder
$clientBuilder->setHosts($hosts); // Set the hosts
$client = $clientBuilder->build();
$params = [
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id',
'body' => ['testField' => 'abc']
];
$response = $client->index($params);
print_r($response);
我明白了!
我只是需要换衣服
$hosts = [
'http://localhost:80', // SSL to localhost
];
到
(删除逗号)奇怪,您在端口80上配置了弹性。如果您没有更改配置,请尝试使用9200。@LeBigCat您的意思是什么?弹性默认端口是9200。如果我正确的话,80就是apache。
$hosts = [
'http://localhost:80' // SSL to localhost
];