phpsymfonyelasticsearchelasticasearchly

Elasticsearch PHP connection settings for searchly.com


I have difficulties connecting to searchly.com with elasticsearch-php (http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/)

$params = array();
    $params['hosts'] = array (
        'https://site:{my-key}@balin-eu-west-1.searchly.com:80'
    );

    $client = new Client($params);

    $em = $this->getContainer()->get('doctrine')->getManager();
    $movies = $em->getRepository("CineupsWebAppBundle:Movie")
        ->getTitlesWithSlug();

    $params = array('index' => 'movies');
    foreach($movies as $movie)
    {
        $params['body'][] = array(
            'title' => $movie['title'],
            'titleDe' => $movie['titleDe'],
            'slugDe' => $movie['slugDe']
        );break;
    }

    $responses = $client->bulk($params);

with port 80 I get:

  [Elasticsearch\Common\Exceptions\TransportException]                 
  error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

without:

  [Elasticsearch\Common\Exceptions\Curl\CouldNotConnectToHost]                       
  Failed to connect to balin-eu-west-1.searchly.com port 9200: Connection timed out

tried connection with curl (put new index)

curl -XPUT http://site:{my-key}@balin-eu-west-1.searchly.com/articles

it works

It seems that I miss some settings for connection, but no idea what :(


Solution

  • Try like:

    $params['hosts'] = array (
        'http://balin-eu-west-1.searchly.com:80'
    );
    $params['connectionParams']['auth'] = array(
        'site',
        'key',
        'Basic' 
    );
    $client = new Elasticsearch\Client($params);
    

    Also please see https://github.com/searchly/searchly-php-sample