Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-142

Geospatial queries: radius search does not filter

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      In http://www.mongodb.org/display/DOCS/Geospatial+Indexing it appears
      you can get a distance back from MongoDB when making queries against a
      model that has this form:

      class User
      ..
      field :latlng, :type => Array
      index [[ :latlng, Mongo::GEO2D ]]
      end

      However, when I do this query (where res is a latitude, longitude
      output from GeoKit):

      @users = User.where(:latlng.within => {"$center" =>
      [ res.ll.split(',').map

      { |ll| ll.to_f }

      , radius ]}).order_by(:dis)

      I get the results back in the correct order based on distance, but it
      does not appear to filter anything out. And @users does not contain
      any distance information.

      Is there a way to access the :dis value from Mongoid or the ruby
      driver? And what am I doing wrong so that the filtering is not working
      correctly?

            Assignee:
            Unassigned Unassigned
            Reporter:
            jadeforrest Jade Rubick
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: