6

我正在尝试让 FOSElasticaBundle 工作。ElasticSearch 实例在 localhost:9200 上运行并响应。

我按照文档中的每个步骤https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/setup.md

但在最后一步,我在控制台中收到此错误:

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]

似乎“__construct”-Function 必须有 3 个参数,但其中只有 2 个。我只是尝试添加“NULL”参数以使其工作,但随后另一个函数引发错误。

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

这是个常见的问题吗?我该如何解决?

4

2 回答 2

7

这是因为 ruflin/Elastica 包还与 elasticsearch 2.0 不兼容。

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

目前的替代方案(直到 ruflin/Elastica 升级 2.0)是使用最新的 1.x 版本。

你可以在这里下载:https ://www.elastic.co/downloads/past-releases/elasticsearch-1-7-3

ES 1.7.3 + FosElasticaBundle(使用 ruflin/Elastica)在 Elasticsearch 1.7.3 版本中运行良好。

于 2015-11-09T15:08:11.410 回答
4

这个问题的原因是,在 elasticsearch 2.0 中,响应错误的结构发生了变化(更多细节在这里:https ://github.com/ruflin/Elastica/issues/946 )。而不是之前的字符串,现在是嵌套数组。Elastica 目前还不能与 elasticsearch 2.0 完全兼容。一旦与 Elasticsearch 2.0 兼容的 Elastica 新版本发布,这可能意味着 foselastica 捆绑包也必须更新,因为这些更改会破坏向后兼容性。另请注意,这不是唯一的向后兼容性破坏性更改。

要跟踪升级进度,请关注此问题:https ://github.com/ruflin/Elastica/issues/946

于 2015-11-09T15:06:25.163 回答