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

No results with $near and $nearSphere queries using 2dsphere indexes and $maxDistance parameter

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.3.2, 2.4.0-rc0
    • Component/s: Geo, Querying
    • Labels:
    • Environment:
      Windows 7 Professional
    • Fully Compatible
    • ALL
    • Hide

      1) Generate documents with 2dsphere index, including Point, LineString, and Polygon
      2) Perform query using $near without $maxDistance – should return documents
      3) Perform query using $near with $maxDistance – returns nothing

      Show
      1) Generate documents with 2dsphere index, including Point, LineString, and Polygon 2) Perform query using $near without $maxDistance – should return documents 3) Perform query using $near with $maxDistance – returns nothing

      Per the current documentation for 2dsphere indexes, queries using $near and $nearSphere require a GeoJSON point passed to them, but otherwise work normally. However, $near and $nearSphere queries against a field with a 2dsphere index return no results if a $maxDistance parameter is provided.

      e.g.
      db.random.find( {geometry: { $nearSphere:

      {type:"Point", "coordinates":[-83,40]}

      }})
      returns results, but

      db.random.find( {geometry: { $nearSphere:

      {type:"Point", "coordinates":[-83,40]}

      , $maxDistance: 10}})
      does not.

            Assignee:
            hari.khalsa@10gen.com hari.khalsa@10gen.com
            Reporter:
            jdagg Jim Dagg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: