0

我正在使用 php 来查询附近的地方。

我在 mongoDB 中有以下 geoJSON

{
                "_id": {
                    "$oid": "dsfsdfsdfsdfsdfsdfsdf"
                },
                "type": "Feature",
                "geometry": {
                    "type": "Point",
                    "coordinates": [
                        125.6342343431232,
                        10.121543413333423
                    ]
                },
                "properties": {
                    "name": "Any Place"
                }
}

我想查询一个点附近的位置,我在 php 中有索引为

$collection->ensureIndex(array("geometry" => "2dsphere"));  

我的查询是:

$arr = $collection->find(array('geometry' =>array('near'=>array("geometry"=>array("type"=>"Point","coordinates"=>$longLat),'minDistance' => 1000,'maxDistance' => 5000 ) ), ));
var_dump($arr->explain());

$arr->explain() 没有给我想要的结果。如果有人可以提供帮助,会有什么问题。

以下是结果

array (size=15)
  'cursor' => string 'BasicCursor' (length=11)
  'isMultiKey' => boolean false
  'n' => int 0
  'nscannedObjects' => int 5
  'nscanned' => int 5
  'nscannedObjectsAllPlans' => int 5
  'nscannedAllPlans' => int 5
  'scanAndOrder' => boolean false
  'indexOnly' => boolean false
  'nYields' => int 0
  'nChunkSkips' => int 0
  'millis' => int 0
  'indexBounds' => 
    array (size=0)
      empty
  'allPlans' => 
    array (size=1)
      0 => 
        array (size=5)
          'cursor' => string 'BasicCursor' (length=11)
          'n' => int 0
          'nscannedObjects' => int 5
          'nscanned' => int 5
          'indexBounds' => 
            array (size=0)
              ...
  'server' => string 'h0043434.mongolab.com:43434' (length=26)

它正在返回 'BasicCursor' ,而应该给出 'S2Cursor'

4

0 回答 0