distinct() broken for indexed geo fields

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.9.0
    • Affects Version/s: 1.7.3
    • Component/s: Geo, Index Maintenance
    • None
    • Environment:
      OS X 64-bit, 1.7.3 prebuilt
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      w/1.7.3, distinct() doesn't seem to work with an indexed geo field, though in it does in 1.6.4.

      To replicate, run these 3 lines in mongo:

      use test_distinct
      db.commits.save(

      { "_id" : ObjectId("4ce63ec2f360622431000013"), "loc" : [ 55.59664, 13.00156 ], "author" : "FredrikL"}

      )
      db.runCommand(

      {distinct: 'commits', key: 'loc'}

      )

      OK, we see one commit. But if the geo field is indexed, we get an exception.

      > db.commits.ensureIndex(

      {'loc': '2d'}

      )
      > db.commits.getIndexes()
      [
      {
      "name" : "id",
      "ns" : "test_distinct.commits",
      "key" :

      { "_id" : 1 }

      ,
      "v" : 0
      },
      {
      "_id" : ObjectId("4ceadeb04ca1623d1ab8bcf3"),
      "ns" : "test_distinct.commits",
      "key" :

      { "loc" : "2d" }

      ,
      "name" : "loc_"
      }
      ]
      > db.runCommand(

      {distinct: 'commits', key: 'loc'}

      )
      {
      "errmsg" : "exception: best guess plan requested, but scan and order required: query: {} order:

      { loc: \"2d\" }

      choices:

      { $natural: 1 }

      ",
      "code" : 13284,
      "ok" : 0
      }

      In 1.6.4, this works (same inputs as above)

      > db.runCommand(

      {distinct: 'commits', key: 'loc'}

      )

      { "values" : [ 13.00156, 55.59664 ], "ok" : 1 }

        1. geo_distinct.js
          0.4 kB
          Greg Studer

            Assignee:
            Greg Studer (Inactive)
            Reporter:
            Brandon Heller
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: