在yaml中的Doctrine ODM @Distance

时间:2015-04-20 17:13:53

标签: mongodb symfony doctrine-orm doctrine doctrine-odm

如何在yaml映射文件中添加@Distance?我尝试过它而不起作用。

CP\AppBundle\Document\Point:
  type: embeddedDocument
  embedOne:
    address:
      targetDocument: CP\AppBundle\Document\Address
    coordinates:
      targetDocument: CP\AppBundle\Document\Coordinates
  distance: distance
  indexes:
    coordinates:
      keys:
        coordinates: 2d

非常感谢!

1 个答案:

答案 0 :(得分:-1)

需要将距离字段指定为具有距离参数的浮点数:

CP\AppBundle\Document\Point:
  type: embeddedDocument
  embedOne:
    address:
      targetDocument: CP\AppBundle\Document\Address
    coordinates:
      targetDocument: CP\AppBundle\Document\Coordinates
  fields:
    distance:
      type: float
      distance: true
  indexes:
    coordinates:
      keys:
        coordinates: 2d