青野 发表于 2018-10-25 08:12:26

Ruby操作MongoDB(进阶十一)--空间信息搜索Geospatial Search

client=Mongo::Client.new(['mongodb://127.0.0.1:27017/test'])  
collection=client[:restaurants]
  

  
collection.find(
  
               {
  
                  "address.coord"=>{
  
                     {"$geoWithIn"=>
  
                        { "$geometry"=>
  
                           {"type"=>"Ploygon",
  
                           "corrdinates"=>[[[-73,48],[-74,41],[-72,39],[-73,40]]]
  
                           }
  
                         }
  
                     }
  
                  }
  
               }
  
               ).each do |doc|
  
               p doc
  
end


页: [1]
查看完整版本: Ruby操作MongoDB(进阶十一)--空间信息搜索Geospatial Search