title: Building the right search request with gem Tire and ElasticSearch
body: <p>I am trying to implement simple search request for my Flower Store, but as I am new to Tire and ElasticSearch, I cannot get how to do it.</p>
  
  <p>I have searchable model <code>Product</code>, and habtm models <code>Category</code>, <code>Colour</code>, <code>Flower</code>. What I want is checkboxes for each association, producing request similiar to this:</p>
  
  <pre><code>http://example.com/search?q=some%20query&amp;category_names[]=bouquet&amp;category_names[]=marriage&amp;colour_names[]=red&amp;colour_names[]=yellow&amp;colour_names[]=white&amp;flower_names[]=rose&amp;flower_names[]=tulip&amp;price_min=100&amp;price_max=1000
  </code></pre>
  
  <p>But I need to show only those products, which:</p>
  
  <pre><code>a) prestent in any of the requested categories (OR);
  b) have all of the requested colours (AND);
  c) have all of the requested flowers (AND);
  d) enter the price range between price_min and price_max.
  </code></pre>
  
  <p>The <code>q</code> parameter is to search any text, entered to the text field, in the names of associations (let's say, <code>red roses bouquet</code>), and show it with the upper criteria too.</p>
  
  <p>For now I have only</p>
  
  <pre><code>class Product
    include Mongoid::Document
  
    include Tire::Model::Search
    include Tire::Model::Callbacks
  
    has_and_belongs_to_many :categories
    has_and_belongs_to_many :colours
    has_and_belongs_to_many :flowers
  
    def self.search(params)
      tire.search(load: true, page: params[:page], per_page: 8) do |search|
        search.query  { string params[:query] } if params[:query].present?
      end
    end
  
    def to_indexed_json
      self.to_json(methods: [:category_names, :colour_names])
    end
  
    def category_names
      self.categories.collect { |c| c.name }
    end
  
    def colour_names
      self.colours.collect { |c| c.name }
    end
  end
  </code></pre>
  
  <p>and do not know how to configure it. I read about <code>filters</code> and <code>facets</code>, but because English is not my native I cannot uderstand what is what and how to use them.</p>