我在本地主机上有一个与laravel的项目,我想在其上配置elasticsearch,但当我配置主机时出现此错误:"主机在elasticsearch中未识别参数"
我试着这样做:
$params = array('hosts' => array('host'=>'localhost'));
或$params = array('hosts' => array('host'=>'127.0.0.1','port'=>8080));
还有其他方式
error have some info:
foreach ($params as $key => $value) {
if (array_search($key, $whitelist) === false) {
throw new UnexpectedValueException($key . ' is not a valid parameter');
}
}
hosts
数组本身不应该是键控的-这基本上就是错误消息所说的:键host
(和port
)是不期望的。
host
键,就像这样:
$params = array('hosts' => array('localhost:8080'));
默认为localhost:9200
。要了解更多细节,请阅读官方文档
就像matpop说的,"hosts"-数组本身没有键。下面是es-documentation中的一个示例。
$params = array();
$params['hosts'] = array (
'192.168.1.1:9200', // IP + Port
'192.168.1.2', // Just IP
'mydomain.server.com:9201', // Domain + Port
'mydomain2.server.com', // Just Domain
'https://localhost', // SSL to localhost
'https://192.168.1.3:9200' // SSL to IP + Port );
$client = new ElasticsearchClient($params);