0

doctrine orm を使用している config.yml でエラスティック検索マッピングを作成しました。問題は、新しいドキュメントを作成すると、「ドキュメント」である最上位のオブジェクトのインデックスが自動入力されることです。 「フォルダー、作成者、コメント...」、フラグまたは設定が欠落している場合、誰かが提案できます。以下は私の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: ~

サンクス。

4

1 に答える 1

0

ここで解決策を見つけました。 更新されたエンティティに関連するすべてのエンティティの Symfony2 FOSElasticaBundle 更新インデックス

注: 私のバージョンの FOSElastica では、Listener は ORM フォルダーではなく FOS\ElasticaBundle\Doctrine にあり、引数は LifecycleEventArgs $eventArgs から \Doctrine\Common\EventArgs $eventArgs に変更されました。

EDIT : この場合、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());
    }
}
于 2014-05-12T15:22:53.300 に答える