Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-47052

MongoDb Geospatial query failure with a valid 2dsphere index via PHP

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      MongoDB 3.4.5
      PHP 5.4.45
      PHP/Mongo Driver 1.6.16

      The query looks like this:
       

      db.profiles.find({"geo":{'$near': {'$geometry':{"type": "Point","coordinates": [lng, lat]},'$maxDistance': 1609}}})
      

      The data set looks like this:
       

      {"_id" : ObjectId("59a48857db5398fbd494314e"),"geo" : {"type" : "MultiPoint","coordinates" : [[-122.1978901,47.61331250000001],[-122.7305319,45.4170443]]}}{"_id" : ObjectId("59a48881db5398fbd4946213"),"geo" : {"type" : "MultiPoint","coordinates" : [[-122.1968714,47.6124774],[-149.8850143,61.1872725],[-122.3312508,47.6064065]]}}
      

      The index looks like this:

      {"v" : 2,"key" : {"geo" : "2dsphere"},"name" : "geo_2dsphere","ns" : "xyz.profiles","2dsphereIndexVersion" : 3}
      

      These are all JSON valid schema, the query is valid per the documentation and the data is being stored as MultiPoint to support the multiple coordinates.

      However, the response when running the query is:
       

      127.0.0.1:27017: error processing query: ns=xyz.profiles ntoreturn=500Tree: GEONEAR  field=geo maxdist=1609 isNearSphere=0Sort: {}Proj: {}planner returned error: unable to find index for $geoNear query"
      

            Assignee:
            carl.champain@mongodb.com Carl Champain (Inactive)
            Reporter:
            mmikhjian@gmail.com Michael Mikhjian
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: