0

I have created an elastic search mapping in config.yml which is using doctrine orm, the issue is that when I create a new document the index is auto populated for the top most object which is "documents" but not for any child objects such as "Folder, Authors, Comments ...", can someone suggest if I am missing any flag or any settings. Below is my Elastica configuration:

# 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.

rene
  • 41,474
  • 78
  • 114
  • 152
DP2
  • 635
  • 9
  • 22

1 Answers1

0

i've found a solution here. Symfony2 FOSElasticaBundle update index for all entities related to the entity updated

Note : In my version of FOSElastica, Listener is not in the ORM folder but in FOS\ElasticaBundle\Doctrine and the argument has changed from LifecycleEventArgs $eventArgs to \Doctrine\Common\EventArgs $eventArgs.

EDIT : For this case, you have to override postPersist too.

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());
    }
}
Community
  • 1
  • 1
jona303
  • 1,358
  • 1
  • 9
  • 27
  • isObjectIndexable - Member has are provate access, and have error Runtime Notice: Declaration of Artel\SiteBundle\EventListener\ElasticaCourseListener::postUpdate() should be compatible with FOS\ElasticaBundle\Doctrine\Listener::postUpdate(Doctrine\Common\Persistence\Event\LifecycleEventArgs $eventArgs) – shuba.ivan Dec 23 '15 at 10:10