dsxfa26482 2014-07-15 05:54
浏览 317

需要帮助解决弹性搜索中的致命错误异常

i am new to elasticSearch please help me out. i have written the following test code in php

<?php
require '../../vendor/autoload.php';
$params = array();
    $params['hosts'] = array (
        'https://localhost',        // SSL to localhost
    );
$params['connectionParams']['auth'] = array(
    'root',
    '',
    'Basic' 
);
    $params1 = array(
        'index'  => 'test_missing',
        'type'   => 'test',
        'id'     => 1,
        'ignore' => 404 
    );
$client = new Elasticsearch\Client($params);
    echo $client->get($params1);

but am getting following fatal error

Fatal error: Uncaught exception 'Elasticsearch\Common\Exceptions\Curl\CouldNotConnectToHost' with message 'Failed connect to localhost:9200; No error' in 
C:\xampp\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\AbstractConnection.php:308 Stack trace: #0 
C:\xampp\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\GuzzleConnection.php(307): Elasticsearch\Connections\AbstractConnection->throwCurlException(7, 'Failed connect ...') #1 
C:\xampp\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\GuzzleConnection.php(197): Elasticsearch\Connections\GuzzleConnection->processCurlError(Object(Guzzle\Http\Exception\CurlException)) #2 
C:\xampp\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\GuzzleConnection.php(104): Elasticsearch\Connections\GuzzleConnection->sendRequest(Object(Guzzle\Http\Message\Request), NULL) #3 
C:\xampp\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Transport.php(166): Elasticsearch\Connections\GuzzleConnection->performRequest('GET', '/test_miss in C:\xampp\vendor\elasticsearch\elasticsearch\src\Elasticsearch\Connections\AbstractConnection.php on line 308

i am using xampp for php in windows 7 thanks in advance.

  • 写回答

1条回答 默认 最新

  • duanmei1350 2014-08-25 02:11
    关注

    Although I have not used https so am not 100% certain of the format for those connections, the code I have here does not specify a protocol within the hosts array (I have a different port number so have it appended to the host, it looks like that's optional but I have included it anyway):

    $params['hosts'] = array('localhost:9200');

    Beyond that the rest looks ok.

    This question might help as well: using https with elasticsearch-php client

    评论

报告相同问题?

悬赏问题

  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决