title: How to access Chewy results with the dot notation?
body: <p>I'm using <a href="https://github.com/toptal/chewy" rel="nofollow noreferrer">Toptal's Chewy gem</a> to connect and query my Elasticsearch, just like an ODM. </p>
  
  <p>I'm using <a href="http://][1]" rel="nofollow noreferrer">Chewy</a> along with Elasticsearch 6, Ruby on Rails 5.2 and Active Record.</p>
  
  <p>I've defined my index just like this:</p>
  
  <pre><code>class OrdersIndex &lt; Chewy::Index
    define_type Order.includes(:customer) do
  
      field :id, type: "keyword"
  
      field :customer do
        field :id, type: "keyword"
        field :name, type: "text"
        field :email, type: "keyword"
      end
    end
  end
  </code></pre>
  
  <p>And my model:</p>
  
  <pre><code>class Order &lt; ApplicationRecord
    belongs_to :customer
  end
  </code></pre>
  
  <p>The problem here is that when I perform any query using Chewy, the customer data gets deserialized as a hash instead of an Object, and I can't use the dot notation to access the nested data.</p>
  
  <pre><code>results = OrdersIndex.query(query_string: { query: "test" })
  results.first.id
  # =&gt; "594d8e8b2cc640bb78bd115ae644637a1cc84dd460be6f69"
  
  results.first.customer.name
  # =&gt; NoMethodError: undefined method `name' for #&lt;Hash:0x000000000931d928&gt;
  
  results.first.customer["name"]
  # =&gt; "Frederique Schaefer"
  </code></pre>
  
  <p>How can I access the nested association using the dot notation (<code>result.customer.name</code>)? Or to deserialize the nested data inside an Object such as a Struct, that allows me to use the dot notation?</p>