title: Elastic Search/Tire: How to map to association attribute?
body: <p>I'm using <a href="https://github.com/karmi/tire" rel="nofollow noreferrer">Tire</a> for Elastic Search. In my application I have 2 models; Price and Product.</p>
  
  <p>I'm trying to search my Price class and use the Product it belongs to's <code>:name</code> attribute for the search field. Right now if I had a product called <code>Product 1</code> and type in "pro", "prod" or "duct", no results come up. But typing "product" or "Product" shows the results. I believe the problem lies in my mapping. I looked at the query and its:</p>
  
  <pre><code>...localhost:3000/search/results?utf8=%E2%9C%93&amp;query=product
  </code></pre>
  
  <p>When I think it should be:</p>
  
  <pre><code>...localhost:3000/search/results?utf8=%E2%9C%93&amp;query:product=product
  </code></pre>
  
  <p>Judging by this question: <a href="https://stackoverflow.com/questions/6226546/elasticsearch-mapping-doesnt-work">ElasticSearch mapping doesn&#39;t work</a></p>
  
  <p>I don't know how to make my <code>params[:query]</code> to take the <code>product.name</code> only though. I tried to use: <code>string params[:query], default_field: "product.name"</code> but that didn't work.</p>
  
  <p>I don't want to use the <code>_all</code> field.</p>
  
  <p>Here is my code:</p>
  
  <p><strong>Price.rb</strong></p>
  
  <pre><code>  include Tire::Model::Search
    include Tire::Model::Callbacks
  
    def self.search(params)
      tire.search(load: true, page: params[:page], per_page: 20) do
         query do
           boolean do
              must { string params[:query] } if params[:query].present?
              must { term :private, false }
           end
         end
         sort do
           by :date, "desc"
           by :amount, "asc"
         end
      end
    end
  
    def to_indexed_json
      to_json( include: { product: { only: [:name] } } )
    end
  
    mapping do
      indexes :id,        type: "integer"
      indexes :amount,    type: "string", index: "not_analyzed"
      indexes :date,      type: "date",   index: "not_analyzed"
      indexes :private,   type: "boolean"
      indexes :product do
        indexes :name, type: "string", analyzer: "custom_analyzer"
      end
    end
  
    settings analysis: {
      analyzer: {
        custom_analyzer: {
          tokenizer: [ "whitespace", "lowercase" ],
          filter: [ "ngram_filter", "word_delimiter_filter" ],
          type: "custom"
        }
      },
      filter: {
        ngram_filter: {
          type: "nGram",
          min_gram: 2,
          max_gram: 15
        }
      },
      filter: {
        word_delimiter_filter: {
          type: "word_delimiter",
          generate_word_parts: true,
          generate_number_parts: true,
          preserve_original: true,
          stem_english_possessive: true
        }
      }
    }
  </code></pre>
  
  <p>So does anyone have any suggestions or know how to set the query field to use the Product name only?</p>
  
  <p>Thank you.</p>