运行此命令时,我的Doctrine ODM文档中有一个嵌入式文档
php app/console fos:elastica:populate
我收到此错误:
人员似乎是什么问题?类ng \ myBundle \ Document \ Coordinates的对象无法在/usr/share/nginx/www/project/vendor/friendsofsymfony/elastica-bundle/FOS/ElasticaBundle/Transformer/ModelToElasticaAutoTransformer.php上转换为字符串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 }
答案 0 :(得分:0)
尝试在没有string
转换的情况下使用此代码:
if ($v instanceof \DateTime) {
$v = $v->format('c');
} elseif (!is_scalar($v) && !is_null($v)) {
//$v = (string)$v // if you want that it work, add `__toString()` magic method in `$v` object class
var_dump($v); // or try to dump var and find to method that you need to call
}