【发布时间】:2018-07-09 00:16:46
【问题描述】:
我正在开发一个处理地理位置信息的 MongoDB 集合。所以,
-
我创建了一个下面的集合索引。
db.places.createIndex( { location: "2dsphere" } ) -
我通过PHP插入并找到了一条记录(使用
phalcon)如下$lng = (float) -73.9667; $lat = (float) 40.78; $m = new Store(); $m->location = [ "type" => 'Point', "coordinates" => [$lng, $lat] ] ; print_r($m->location); $m->save(); ... $params = [ [ "location" => [ '$near' => [ '$geometry' => [ "type" => "Point", "coordinates" => [ $lng, $lat ] ], '$minDistance' => 1, '$maxDistance' => 5000 ] ] ] ]; $find = Store::find($params); print_r(count($find));
我收到以下错误消息:
PHP Fatal error: Uncaught exception 'MongoWriteConcernException'
with message 'localhost:27017: location object expected, location array
not in correct format' in /var/www/html/muyal/cli/tasks/MedicineTask.php:51
我认为 2dshere 格式不正确,是吗?
【问题讨论】: