title: ElasticSearch match multiple fields with different values
body: <p>I can actually perform a simple match search with this:</p>
  
  <pre><code>query: {match: {searchable: {query:search}}}
  </code></pre>
  
  <p>This works well, my searchable field is analyzed in my mapping.</p>
  
  <p>Now I want to perform a search on multiple fields: 1 string, and all other are numeric.</p>
  
  <p>My mapping:</p>
  
  <pre><code>mappings dynamic: 'false' do
          indexes :searchable, analyzer: "custom_index_analyzer", search_analyzer: "custom_search_analyzer"
          indexes :year, type: "integer"
          indexes :country_id, type: "integer"
          indexes :region_id, type: "integer"
          indexes :appellation_id, type: "integer"
          indexes :category_id, type: "integer"
        end
  
  def as_indexed_json(options={}) 
        as_json(
          only: [:searchable, :year, :country_id, :region_id, :appellation_id, :category_id]
        ) 
      end 
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>query: {
                      filtered: {
                        query: {
                          match: {
                            searchable: search
                          }
                        },
                        filter: {
                          term: {
                            country_id: "1"
                          },
                          term: {
                            region_id: "2"
                          },
                          term: {
                            appellation_id: "34"
                          }
                        }
                      }
                    },
                    sort: {
                      _score: {
                        order: :desc
                      }, 
                      year: {
                        order: :desc, 
                        ignore_unmapped: true
                      }
                    },
                    size:100
  </code></pre>
  
  <p>It works well but it will give me 100 results in all cases, from the appellation_id sent (34), even if the searchable field is very far from the text search.</p>
  
  <p>I have also tried a BOOL query:</p>
  
  <pre><code>  self.search(query: {
                  bool: {
                    must: [
                      {
                        match: {
                              country_id: "1"
                            },
                            match: {
                              region_id: "2"
                            },
                            match: {
                              appellation_id: "34"
                            },
                            match: {
                              searchable: search
                            }
                      }
                    ]
                  }
                },
                sort: {
                  _score: {
                    order: :desc
                  }, 
                  year: {
                    order: :desc, 
                    ignore_unmapped: true
                  }
                },
                size:100
              )
  </code></pre>
  
  <p>But It will give me all results matching the searchable field and don't take care of the appellation_id wanted.</p>
  
  <p>My goal is to get the best results and performance and ask ES to give me all data from country_id=X, region_id=Y, appellation_id=Z and finally perform a match on this set of results with the searchable field... and don't obtain results to far from reality with the searchable text.</p>
  
  <p>Thanks.</p>