【问题标题】:FOSElasticaBundle indexing hidden objectsFOSElasticaBundle 索引隐藏对象
【发布时间】:2014-04-04 01:09:04
【问题描述】:

我已经安装了FOSElasticaBundle,我的配置fos_elastica.yml如下:

 fos_elastica:
 clients:
     default: { host: localhost, port: 9200 }
 indexes:
     test:
         client: default
         index_name : %elastica_index_name%
         types:
             exhibition:
                 mappings:
                     name : { boost: 100 }
                     company: { boost: 9 }
                     directions: { boost: 8}
                     tags: { boost: 7 }
                     description : { boost: 6 }
                     status : ~
                 persistence:
                     driver: orm
                     model: Test\MainBundle\Entity\Exhibition
                     finder: ~
                     provider: ~
                     listener:
                         is_indexable_callback: "isPublic"

坚持is_indexable_callback 有效。但是当我运行fos:elastica:populate 时,即使是隐藏对象也会创建索引。

如何仅索引活动对象?也许使用分析器或类似的东西?

提前致谢!

【问题讨论】:

    标签: symfony elasticsearch foselasticabundle


    【解决方案1】:

    您应该指定:

    provider:
        query_builder_method: createSearchIndexQueryBuilder
    

    然后将方法添加到相关的Entity\Repository:

    public function createSearchIndexQueryBuilder()
    {
        $qb = $this->createQueryBuilder()
        //->write_magic_here;
    
        return $qb;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-03
      • 1970-01-01
      • 2017-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多