Symfony2 FOSElasticaBundle update index for all entities related to the entity updated

前端 未结 7 1511
無奈伤痛
無奈伤痛 2020-12-30 06:07

I\'m using FOSElasticaBundle and Doctrine in my project, and my code works for the selective index update using the Doctrine lifecycle events. The issue I come up against is

7条回答
  •  别那么骄傲
    2020-12-30 06:29

    with all comments and my research, I made a generic Gist for auto index child objects with fosElastica:

    https://gist.github.com/Nightbr/ddb586394d95877dde8ed7445c51d973

    In fact, I override the default Listener from FOSElastica and I add the function updateRelations($entity). We will search all relations linked to the $entity and if there are indexed in ES (the ES type exists) it will update the related documents.

    If anyone want to look at it and make any improvement it would be great! ^^

    Thanks in advance

提交回复
热议问题