【发布时间】:2014-01-24 20:13:22
【问题描述】:
当我运行此命令时,我的 Doctrine ODM 文档中有一个嵌入文档
php app/console fos:elastica:populate
我收到此错误:
在线/usr/share/nginx/www/project/vendor/friendsofsymfony/elastica-bundle/FOS/ElasticaBundle/Transformer/ModelToElasticaAutoTransformer.php中的ng\myBundle\Document\Coordinates类的对象无法转换为字符串139
似乎是什么问题,警官?
从 137 到 141 的代码:
if ($v instanceof \DateTime) {
$v = $v->format('c');
} elseif (!is_scalar($v) && !is_null($v)) {
$v = (string)$v;
}
我的映射:
mappings:
title: { boost: 5 }
coordinates: {type:geo_point,lat_lon:true, boost: 5 }
【问题讨论】:
-
请在
ModelToElasticaAutoTransformer.php的137-141行显示您的代码 -
我更新了我的问题
-
当我说它的类型是 geo_point 时,我不知道它为什么要尝试将其转换为字符串 ..
-
您将
$v对象转换为标量string类型。如果你想让它起作用,你必须在你的$v对象类中添加__toString()魔法方法
标签: symfony doctrine-orm elastica