【问题标题】:Error in ResponseExeption while populating FOSElasticaBundle/Symfony2填充 FOSElasticaBundle/Symfony2 时 ResponseExeption 出错
【发布时间】:2015-10-20 06:24:58
【问题描述】:

我正在尝试让 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());
}

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

【问题讨论】:

  • stackoverflow.com/questions/21684388/… 的可能重复项(您必须将 PHP 版本更新到 5.3)
  • 我的 PHP 版本是 5.6.3
  • 好的,你说得对,这不是PHP版本的问题。看代码,问题一定是$response->getError()没有返回字符串。我查看了代码,无法弄清楚为什么会发生这种情况。
  • 你找到什么了吗?同样的问题。
  • 我在将 elasticsearch 1.7.3 升级到 2.0 时遇到了这个问题,这不是 foselastica 的问题,而是 foselastica 使用的 ruflin/Elastica 的问题,我已将票移到那里:@987654323 @

标签: symfony exception elastica foselasticabundle


【解决方案1】:

这是因为 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 版本中运行良好。

【讨论】:

【解决方案2】:

这个问题的原因是,在 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

【讨论】:

  • 嗨 ruflin,在简单地“杀死”这个错误消息之后,我的应用程序工作得很好。在我的情况下,我没有看到任何其他问题。最好的问候!
  • 我还注释掉了错误结构并能够继续成功
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-19
  • 2018-11-10
  • 2014-08-18
  • 2010-10-31
  • 2015-06-19
  • 1970-01-01
相关资源
最近更新 更多