Search code examples
phpsymfonyelasticsearchfoselasticabundle

FOSElasticaBundle mapping array


I try add mapped field to elastica

mapping config:

persistence:
                driver: orm
                model: PlaceBuundle\Entity\Place
                finder: ~
                provider: ~
                listener: ~

.....


                activePortals :
                      type: object
                      properties :
                          id:
                              type: integer
                  portalsSort:
                      type: object
                      properties:
                          id: ~
                          value: ~  

in entity

public function getPortalsSort(){

        return array(
            array('id'=>1,'value'=>10)
        );

    }

error

 [Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException]                                       
  Cannot read property "id" from an array. Maybe you intended to write the property path as "[id]" instead.

there is no type: array

what is easiest way to map array values ?


Solution

  • The answer is to use:

    activePortals:
        type: nested
        properties :
            id:
                type: integer