title: Elasticsearch: filtering by group with tire gem
body: <p>I want to filtering search by age groups.</p>
  
  <p>Now I have:
  <strong>program.rb</strong></p>
  
  <pre><code>class Program &lt; ActiveRecord::Base
    has_many :age_groups, through: :programs_age_groups_relations
    include Tire::Model::Search
    include Tire::Model::Callbacks
    mapping do
      indexes :name, analyzer: 'snowball', boost: 100
      indexes :description, analyzer: 'snowball'
      indexes :age_groups do
        indexes :name, analyzer: 'snowball'
      end
    end
  
    def to_indexed_json
      to_json(include: {age_groups: {only: :name}})
    end
    def self.search(params, options={})
      tire.search(load: {include: 'age_groups'}) do
        query do
          boolean do
            must { string params[:name_query] } if params[:name_query].present?
          end
        end
  
      filter do
        boolean do
          if params[:age_groups].present?
            params[:age_groups].each do |ag_name|
              must { string ag_name }
            end
          end
        end
      end
    end
  end
  </code></pre>
  
  <p><strong>index.html.haml</strong></p>
  
  <pre><code>= form_tag programs_path, method: :get do |f|
    = text_field_tag :name_query, params[:name_query]
    - AgeGroup.all.each do |ag|
      = check_box_tag 'age_groups[]', ag.name, params[:age_groups].include?(ag.name)
  </code></pre>
  
  <p>in controller:</p>
  
  <pre><code>@programs = Program.search(params)
  </code></pre>
  
  <p>Age Groups:</p>
  
  <pre><code>AgeGroup.create([{name: 'Baby'}, {name: 'Toddler'}, {name: 'Preschoolers'}, {name: 'Elementary'}, {name: 'Middle School'}])
  </code></pre>
  
  <p>Realtion:</p>
  
  <pre><code>class ProgramsAgeGroupsRelation &lt; ActiveRecord::Base
    attr_accessible :age_group_id, :program_id
    belongs_to :age_group
    belongs_to :program
  end
  </code></pre>
  
  <p>When I check one or more age_groups in search form nothing was happened with  search result.</p>
  
  <p>How can I correctly use tire for this task?</p>