title: ElasticSearch and searching on multiple fields in PHP
body: <p>I am using the latest version of <a href="https://github.com/elasticsearch/elasticsearch-php" rel="nofollow">elasticsearch-php</a> as well as the latest version of MongoDB and ElasticSearch.</p>
  
  <p>I need to do a search on multiple fields that can contain one or multiple values. Example:</p>
  
  <p>country_code should be either NL, BE or DE
  AND
  category should contain be AA01, BB01, CC02 or ZZ11</p>
  
  <p>I thought I would solve it as followed (PHP):</p>
  
  <pre><code>$countries = array(“NL”, “BE”, “DE”);
  $category = array(“AA01”, “BB01”, “CC02”, “ZZ11”);
  
  $searchParams['body']['query']['bool']['must']['terms']['country'] = $countries;
  $searchParams['body']['query']['bool']['must']['terms']['categories'] = $category;
  $searchParams['body']['query']['bool']['must']['terms']['minimum_should_match'] = 1;
  </code></pre>
  
  <p>But the result does not even come close the the data that I expect to get back.</p>
  
  <p>Sometimes <em>$countries</em> and/or <em>$category</em> can only have one element.</p>