host不是elasticsearch中的公认参数

时间:2014-06-18 12:33:38

标签: search laravel parameters elasticsearch params

我在我的localhost上有一个带laravel的项目,我想在它上面配置elasticsearch但是当我配置我的主机时出现这个错误:“主机在弹性搜索中不被识别参数”

无论如何我都会尝试:

$params = array('hosts' => array('host'=>'localhost'));

$params = array('hosts' => array('host'=>'127.0.0.1','port'=>8080)); 和其他一些方式

错误有一些信息:

foreach ($params as $key => $value) {
        if (array_search($key, $whitelist) === false) {
            throw new UnexpectedValueException($key . ' is not a valid parameter');
        }
    }

2 个答案:

答案 0 :(得分:1)

hosts数组本身不应该被键入 - 这基本上就是错误消息所说的内容:键host(和port)不是预期的。< / p>

在您的代码中,请尝试不使用host密钥,就像这样:

$params = array('hosts' => array('localhost:8080'));

默认值为localhost:9200。有关详细信息,请阅读official documentation

答案 1 :(得分:0)

就像matpop所说,&#34;主持人&#34; -array本身没有键入。这是es文档中的一个例子。

$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 Elasticsearch\Client($params);