我使用控制台命令将MySQL数据库的“文档”由ElasticSearch用FOSElasticaBundle for Symfony2进行索引:
php app/console fos:elastica:populate我不希望那些列为"online“的文档被编错索引。
我要做些什么来配置这个需求?
发布于 2015-02-26 11:38:54
可以在指数化过程中添加回调,以检查对象是否需要索引。
只需像这样在配置中添加indexable_callback:
types: document: indexable_callback: 'isIndexable'
在这种情况下,您必须在关联对象中编写一个isIndexable方法,例如:
public function isIndexable() { return $this->getOnline() && $this->getPublished(); }
发布于 2015-02-25 21:31:01
您必须创建一个自定义的Document,在这里您将检查online是否为true,如果是的话-返回一个新的文档实例。
FosElasticaBundle为每个文档提供程序提供了一个名为ProviderInterface的接口,您可以创建实现该接口的服务,并将其标记为"fos_elastica.provider“。
就像这样:
<service id="service.id" class="Some\Bundle\Some\Class">
<tag name="fos_elastica.provider" index="<index>" type="<type>" />
<argument type="service" id="fos_elastica.index.<index>.<type>" />
<argument type="service" id="logger" />
<argument type="service" id="op.search.loader.product" />
<argument>150</argument>
</service>该服务将负责填充特定的索引类型。该服务将实现填充方法,在该方法中,您可以编写自己的逻辑,如何填充该类型。
https://stackoverflow.com/questions/28725611
复制相似问题