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

wrong distance calcul when GeoNear used with aggregate

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.6
    • Component/s: Aggregation Framework, Geo
    • Labels:
      None
    • ALL
    • Hide

      this distance query output without aggregation is correct :
      QUERY A

      db.runCommand( {      
          geoNear: "tablegui",
          near: [2.298800, 48.854355], 
          maxDistance:20000000/6371 ,
          distanceMultiplier: 6371 ,   
          spherical: true,   
          query: { code_postal : { $gt : 30000 }     } ,
          limit:500}
               );
      

      This one with aggregation is not :
      QUERY B

      db.tablegui.aggregate([
      
         {
           $geoNear: {
              near: { type: "Point", coordinates: [2.298800, 48.854355] },
              distanceField: "dist.calculated",
              distanceMultiplier: 6371 ,     
              maxDistance:20000000/6371 ,
              query: { code_postal:  { $gt : 30000 }   },
             limit:20000,   
             spherical: true 
           }
         }
      
          , { $project : { _id : 0  , ville : 1 , code_postal:1 , "dist.calculated":1  } } 
      
      ]
         
        
       )
      
      Show
      this distance query output without aggregation is correct : QUERY A db.runCommand( { geoNear: "tablegui" , near: [2.298800, 48.854355], maxDistance:20000000/6371 , distanceMultiplier: 6371 , spherical: true , query: { code_postal : { $gt : 30000 } } , limit:500} ); This one with aggregation is not : QUERY B db.tablegui.aggregate([ { $geoNear: { near: { type: "Point" , coordinates: [2.298800, 48.854355] }, distanceField: "dist.calculated" , distanceMultiplier: 6371 , maxDistance:20000000/6371 , query: { code_postal: { $gt : 30000 } }, limit:20000, spherical: true } } , { $project : { _id : 0 , ville : 1 , code_postal:1 , "dist.calculated" :1 } } ] )

      wrong distance calcul when GeoNear used with aggregate .

      The same Geonear query with same distanceMultiplier
      and maxDistance parameters don't return the same distance calcul output when it 's querying with or without
      aggregation.

      When query A return 1.59861657499673,
      query B return 10196136.37698665

      Divion by 1000 isnot indicate in manual if i didn't miss something..

            Assignee:
            siyuan.zhou@mongodb.com Siyuan Zhou
            Reporter:
            pulsar guipulsar
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: