Welcome Guest, Not a member yet? Register   Sign In
Composer problem (500 Internal Server)
#1

[eluser]CJL01[/eluser]
I'm trying to add the ElasticSearch PHP client (https://github.com/nervetattoo/elasticsearch) to my CI project using composer. The install went cleanly and I can see the ./vendor directory no problem. I included '/vendor/autoload.php' in my index.php file, but I'm struggling to use the library in my code.

The readme for the package (copied from github) says I should use:

Code:
use \ElasticSearch\Client;
$es = Client::connection('http://127.0.0.1:9200/myindex/mytype');

But the 1st line doesn't seem to make sense as PHP is rejecting the initial slash resulting in a 500 Server Error. Removing it doesn't work either...

Any ideas?
#2

[eluser]CJL01[/eluser]
After many different permutations I finally stumbled on the solution, which is to simply merge the two lines.
I also needed to change to a different way of making the connection using an array instead of a URL.

Code:
$es = \ElasticSearch\Client::connection(array('servers' => '127.0.0.1:9200',
                                                      'protocol' => 'http',
                                                      'index' => null,
                                                      'type' => null));
        $result = $es->search(.....

Hope this can help somebody else.




Theme © iAndrew 2016 - Forum software by © MyBB