我在config.yml中创建了一个使用doctrine orm的弹性搜索映射,问题是当我创建一个新文档时,索引是自动填充的最顶层对象是"文档"但是对于任何子对象,例如"文件夹,作者,评论...",如果我遗漏任何标记或任何设置,有人可以建议。以下是我的Elastica配置:
# Elastica Configuration
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
website:
client: default
index_name: docova
types:
documents:
mappings:
Doc_Title: ~
Description: ~
Date_Created: ~
Doc_Status: ~
Keywords: ~
folder:
type: "object"
properties:
id: ~
Library:
type: "object"
properties:
id: ~
Author:
type: "object"
properties:
username: ~
Comments:
type: "object"
properties:
comment: ~
Form_Values:
type: "object"
properties:
Field_Value: ~
Bookmarks:
type: "object"
properties:
Target_Folder:
type: "object"
properties:
id: ~
DocType:
type: "object"
properties:
id: ~
Doc_Name: ~
Attachments:
type: "object"
properties:
File_Name:
content:
type: attachment
persistence:
driver: orm
model: Docova\DocovaBundle\Entity\Documents
provider: ~
listener: ~
finder: ~
日Thnx。
答案 0 :(得分:0)
我在这里找到了解决方案。 Symfony2 FOSElasticaBundle update index for all entities related to the entity updated
注意:在我的FOSElastica版本中,Listener不在ORM文件夹中,而是在FOS \ ElasticaBundle \ Doctrine中,并且参数已从LifecycleEventArgs $ eventArgs更改为\ Doctrine \ Common \ EventArgs $ eventArgs。
编辑:对于这种情况,你也必须覆盖postPersist。
public function postPersist(\Doctrine\Common\EventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if ($entity instanceof $this->objectClass && $this->isObjectIndexable($entity)) {
$this->scheduledForInsertion[] = $entity;
$this->inicializaPost();
$this->objectPersisterPost->replaceOne($entity->getPost());
}
}