6

I am trying to get FOSElasticaBundle to work. ElasticSearch Instance is running on localhost:9200 and responding.

I followed each step in the docs https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/setup.md

but at the last step, I get this error in my console:

c:\xampp\htdocs\my\folder>php app/console fos:elastica:populate
Resetting app

Fatal error: Wrong parameters for Exception([string $exception [, long $code [,
Exception $previous = NULL]]]) in C:\xampp\htdocs\my\folder\vendor\rufli
n\elastica\lib\Elastica\Exception\ResponseException.php on line 34

[Symfony\Component\Debug\Exception\FatalErrorException]

Error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])


fos:elastica:populate [--index[="..."]] [--type[="..."]] [--no-reset] [--offset="..."] [--sleep="..."] [--batch-size="..."] [--ignore-errors] [--no-overwrite-format]

It seems like there are 3 parameters mandatory for "__construct"-Function, but there are only 2 of them. I've simply tried to add "NULL"-parameter to get it work, but then another function throws an error.

public function __construct(Request $request, Response $response)
{
    $this->_request = $request;
    $this->_response = $response;
    parent::__construct($response->getError());
}

Is this a common problem? How do I solve it?

RoyRobsen
  • 457
  • 1
  • 9
  • 20
  • Possible duplicate of http://stackoverflow.com/questions/21684388/wrong-parameters-for-exception-when-creating-exception-subclass (you must update your PHP version to 5.3) – Carlos Granados Oct 20 '15 at 08:00
  • 1
    My PHP-Version is 5.6.3 – RoyRobsen Oct 21 '15 at 07:05
  • OK, you are right this is not a problem of PHP version. Looking at the code, the problem must be that $response->getError() does not return a string. I looked at the code and could not figure out why this could happen. – Carlos Granados Oct 21 '15 at 08:05
  • Did you find anything? Same problem here. – MaximeBernard Nov 09 '15 at 10:37
  • I got this issue upgrading elasticsearch 1.7.3 to 2.0, this is not an issue with foselastica, but rather with ruflin/Elastica which is used by foselastica, I've moved the ticket there: https://github.com/ruflin/Elastica/issues/974 – Anil Nov 09 '15 at 14:55
  • -Anil- is right. This is not an issue with foselastica. There is a weird behaviour, but I got my server working. I did this with a dirty trick: Just add to the "__contruct" function -> "HttpKernelInterface $kernel," – RoyRobsen Nov 09 '15 at 14:58

2 Answers2

7

This is because the ruflin/Elastica package is not compatible with elasticsearch 2.0 yet.

https://github.com/ruflin/Elastica/issues/946

An alternative for now (until ruflin/Elastica is 2.0 upgraded), is to use the latest 1.x version.

You can download it here: https://www.elastic.co/downloads/past-releases/elasticsearch-1-7-3

ES 1.7.3 + FosElasticaBundle (which uses ruflin/Elastica) works fine with Elasticsearch 1.7.3 version.

Anil
  • 21,730
  • 9
  • 73
  • 100
  • confirm resolved error above with this version: https://www.elastic.co/downloads/past-releases/elasticsearch-1-7-3 (thanks Anil!) – Dung Mar 28 '16 at 03:04
4

The reason for this issue is, that with elasticsearch 2.0 the structure of the response error changed (more details here: https://github.com/ruflin/Elastica/issues/946). Instead of a string before it is now a nested array. Elastica is currently not yet fully compatible with elasticsearch 2.0. As soon as a new release of Elastica is out which is compatible with Elasticsearch 2.0 it will probably mean that also foselastica bundle will have to be updated as these changes will break backward compatibility. Be also aware, that this is not the only backward compatibility breaking change.

To follow the progress of the upgrade, follow this issue: https://github.com/ruflin/Elastica/issues/946

ruflin
  • 206
  • 1
  • 3
  • Hi ruflin, after simply "killing" this error message, my application is working just fine. I don't see any more issues in my case. Best regards! – RoyRobsen Nov 09 '15 at 15:40
  • I also commented out the error construct and was able to move on success – vrwired Dec 16 '15 at 00:18