ElasticaBundle and ORM join


(NicoB) #1

Hi,

I try to use ElasticaBundle with this config in Symfony2 :

                mappings:
                    location: {type: geo_point}
                    user:
                      type: object
                      fields:
                        id: {}
                        firstName: { type: string }
                persistence:
                    driver: orm
                    model: CoreBundle\Entity\MyEntity
                    provider:
                        query_builder_method:

createIsActiveQueryBuilder

My object have many relations that I want to index.

But with this config, I recover just the __toString of user, like
this:
{"location":"47.2711117,6.0282445","user":"Johan"}

Not the properties, so the only way to recover the full relationship
object is to do this :
mappings:
location: {type: geo_point}
user.id: {}
user.firstName: { type: string }

that store this :
{"location":"47.2711117,6.0282445","user.id":
14985,"user.firstName":"Johan"}

but it's not good for do elastic request, I just want the
representation of my object, and compatible with oneToMany relations :
{"location":"47.2711117,6.0282445","user"{"id":
14985,"firstName":"Johan"}}

If somebody have already do this with this Bundle and Doctrine2,
thanks

Nico


(system) #2