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

distinct() broken for indexed geo fields

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 1.9.0
    • 1.7.3
    • Geo, Index Maintenance
    • None
    • OS X 64-bit, 1.7.3 prebuilt
    • ALL

    Description

      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 }

      Attachments

        Activity

          People

            greg_10gen Greg Studer
            brandonh Brandon Heller
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: