title: Query Multi-location in MongoDB using Mongoid
body: <p>I'm trying to query a document using spatial indexes.</p>
  
  <p>According to <a href="http://docs.mongodb.org/manual/core/geospatial-indexes/#multi-location-documents" rel="nofollow">docs</a> my model looks like:</p>
  
  <pre><code>class Trip
    include Mongoid::Document
    field :addresses, :type =&gt; Array
    index({"addresses.loc" =&gt; "2d"}, {:min =&gt; -180, :max =&gt; 180})
  end
  </code></pre>
  
  <p>Addesses are stored like this</p>
  
  <pre><code>Trip.first.addresses
  =&gt; [{"context"=&gt;"from", "loc"=&gt;[-71.55234, -33.024527]}, {"context"=&gt;"to", "loc"=&gt;[-70.641997, -33.4691199]}]
  </code></pre>
  
  <p>I would like to query documents that match address.loc and address.context using this query:</p>
  
  <pre><code>Trip.where("addresses.loc" =&gt; {"$nearSphere" =&gt; [-70.641997, -33.4691199], "$maxDistance" =&gt; 0.005052092295133236}).where("addresses.context" =&gt; "to")
  </code></pre>
  
  <p>The query returns proper values but it seems to be ignoring the "address.context".
  I'm I doing it the proper way ?</p>
  
  <p>Thanks !</p>