title: Finding distinct rows in scope with mongoid
body: <p>I have two models in my rails project: persons and an embeded collection, cities. there is also a spatial index on the cities. I want to find all persons near one city.</p>
  
  <pre><code>class Person
   include Mongoid::Document
   include Mongoid::Timestamps
   embeds_many :cities
   scope :nearby, -&gt;(location, distance) { where('cities.location' =&gt; 
                      {'$near' =&gt; location , '$maxDistance' =&gt; distance})}
  
  
  class City
    include Mongoid::Document
    include Mongoid::Timestamps
    embedded_in :person
    field :city
    field :location, type: Array  #0: latitude, 1: longitude
  
  location_in_new_york = [40.71892, -74.00131]
  </code></pre>
  
  <p>My query would be</p>
  
  <pre><code>Person.nearby(location_in_new_york, 1)
  </code></pre>
  
  <p>But doing so a person with two cities which are very close to each other get found twice. How can I avoid this behavior? I dont want to reduce this in ruby, because I would like to keep my scope.</p>