【问题标题】:Undefined index on FOSElasticaBundleFOSElasticaBundle 上的未定义索引
【发布时间】:2015-04-20 16:35:59
【问题描述】:

我在 Symfony2 上安装了 FOSElasticaBundle 以在 elasticsearch 上查找数据。我按照说明进行操作,但出现错误,我不知道如何处理。错误如下:

注意:未定义索引:bluecoat-syslog

500 内部服务器错误 - ContextErrorException

堆栈跟踪

in vendor/friendsofsymfony/elastica-bundle/Transformer/ElasticaToModelTransformerCollection.php at line 56   -
    $transformed = array();
    foreach ($sorted as $type => $objects) {
*       $transformedObjects = $this->transformers[$type]->transform($objects);
        $identifierGetter = 'get'.ucfirst($this->transformers[$type]->getIdentifierField());
        $transformed[$type] = array_combine(
            array_map(

我的控制器

public function reportAction(Request $request)
{
    $finder = $this->container->get('fos_elastica.finder.log');

    $results = $finder->find('ERROR');

    $parameters = array("results" => $results);

    return $this->render('MyBundle:Core:report.html.twig', $parameters);
}

我的 config.yml

fos_elastica:
    clients:
        default: { host: localhost, port: 9200 }
    indexes:
        log:
            client: default
            index_name: log-2015.04.20
            finder: ~
            types:
                bluecoat-syslog:
                    mappings:
                        message: ~

捆绑的版本是:

FOSElasticaBundle 3.1.x

问候和感谢!

【问题讨论】:

  • 当前 FOSElasticaBundle 稳定版本为 3.1.3。你确定你的意思是 1.3.x 版本吗?
  • jejeje 你是对的!我的版本是 3.1.3。谢谢
  • 如果您的索引名称中有连字符导致问题,请尝试引用 'bluecoat-syslog':。愚蠢的问题,但你确实运行了app/console fos:elastica:populate,对吧? :)
  • 愚蠢的回答,这完全有必要吗?因为我用logstash填充了elasticsearch。我只使用了 FOSElasticaBundle 来搜索

标签: symfony elasticsearch elastica foselasticabundle


【解决方案1】:
  1. 将索引的名称更改为不带-的名称

  2. 不要忘记使用以下命令创建索引 php app/console fos:elastica:populate

【讨论】:

    猜你喜欢
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-08
    • 2012-09-18
    • 1970-01-01
    相关资源
    最近更新 更多