title: Elasticsearch filtering with input array where
body: <p>Our requirement is to filter objects by an array field of data by giving an input array to elasticsearch. Any combination input array elements is match with <strong>mentions</strong> array.</p>
  <h3>Small example</h3>
  <pre><code>data:[
    {&quot;name&quot;: &quot;xxxx&quot;, &quot;mentions&quot;: [&quot;X&quot;, &quot;Y&quot;]},
    {&quot;name&quot;: &quot;yyyy&quot;, &quot;mentions&quot;: [&quot;K&quot;, &quot;L&quot;, &quot;M&quot;]},
    {&quot;name&quot;: &quot;zzz&quot;, &quot;mentions&quot;: [&quot;X&quot;, &quot;L&quot;]},
  ]  
  Input: [X, Y, K, L]
  Output:[
    {&quot;name&quot;: &quot;xxxx&quot;, &quot;mentions&quot;: [&quot;X&quot;, &quot;Y&quot;]},
    {&quot;name&quot;: &quot;zzz&quot;, &quot;mentions&quot;: [&quot;X&quot;, &quot;L&quot;]}
  ]
  </code></pre>
  <p>Objects must be filtered according to <strong>mentions</strong> field, where each member of mentions array must be in the given input array, if there is any inconsistency, then ignore the object.
  <strong>Terms</strong> query or bool with must field is not solving our problem.</p>