title: mongoid / mongodb - Geospatial queries on embedded document
body: <p>it is possible to do a geospatial query on the embedded document and have a "flat" results?</p>
  
  <pre><code>Class a
    ....
    embeds_many : bs
  end
  
  
  Class b
     ....
     field :location, :type =&gt; Array
  
     embedded_in :a, :inverse_of =&gt; :b
     index [[:location, Mongo::GEO2D]]
  end
  </code></pre>
  
  <p>I was able to push the indexation in the mongo console</p>
  
  <pre><code>db.a.ensureIndex({"bs.location" : "2d"})
  </code></pre>
  
  <p>And then was able to query from the mongo console</p>
  
  <pre><code>db.a.find( { 'b.location' : { $near : [50,50] } # mongo console 
  </code></pre>
  
  <p>However, the results is a list of "a" Documents, and not a list of "b" objects.</p>
  
  <p>Two question:
  1* It is what I am trying to do doable? (I know [and follow the virtual collection Jira] <a href="http://jira.mongodb.org/browse/SERVER-142" rel="nofollow">http://jira.mongodb.org/browse/SERVER-142</a>)</p>
  
  <p>2* If yes, how can it be accomplished in Mongoid?</p>
  
  <p>If not, the only option I will have will be to remove the embedded collection and move to a "classic" reference / is_referenced couple of classes.</p>