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

$near query not working with compound 2dsphere index

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.5
    • Component/s: Geo
    • Labels:
      None

      Running the following query:

      db.routeResult.find({ "customerId" : "24585", "assetId" : "451219", "coordinate" : { "$near" : [-0.0843918, 51.5136045], "maxDistance" : 0.0025232195545501768 } });
      

      ...on a collection with the following shape of documents:

      {
        "_id" : ObjectId("52f0f3e295e914f87d13198d"),
        "customerId" : "23138",
        "assetId" : "426598",
        "coordinate" : {
          "longitude" : -1.4841666,
          "latitude" : 52.938473
        }
      

      ...with the following geospatial index:

      { "customerId" : 1, "assetId" : 1, "coordinate" : "2dsphere"}
      

      ....results in the following error being raised in the mongod logs:

      2014-02-05T11:50:22.473+0000 [conn2] assertion 17007 Unable to execute query: error processing query: ns=stuarttest.routeResult limit=50 skip=0
      Tree: $and
          assetId == "451219" First: notFirst: 0 1 4 full path: assetId
          customerId == "24585" First: 0 1 2 3 4 notFirst: full path: customerId
          GEONEAR  field=coordinate maxdist=1.79769e+308 isNearSphere=0 First: notFirst: full path: coordinate
      Sort: {}
      Proj: {}
       planner returned error: unable to find index for $geoNear query ns:stuarttest.routeResult query:{ customerId: "24585", assetId: "451219", coordinate:
       { $near: [ -0.0843918, 51.5136045 ], maxDistance: 0.002523219554550177 } }
      2014-02-05T11:50:22.477+0000 [conn2]  ntoskip:0 ntoreturn:50
      

      Can you confirm why this might be happening?

            Assignee:
            Unassigned Unassigned
            Reporter:
            stuart.hall@masternaut.com Stuart Hall
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: