title: How to formulate an and condition for a nested object in Opensearch?
body: <p>Opensearch ingests documents similar to this example (its just a minimal example):</p>
  <pre class="lang-json prettyprint-override"><code>PUT nested_test/_doc/4
  {
      &quot;log&quot;: &quot;This is a fourth log message&quot;,
      &quot;function&quot;: &quot;4 test function&quot;,
      &quot;related_objects&quot;: [
      { &quot;type&quot;: &quot;user&quot;, &quot;id&quot;: &quot;10&quot; },
      { &quot;type&quot;: &quot;offer&quot;, &quot;id&quot;: &quot;120&quot; }
      ]
  }    
  PUT nested_test/_doc/5
  {
      &quot;log&quot;: &quot;This is a fifth log message&quot;,
      &quot;function&quot;: &quot;5 test function&quot;,
      &quot;related_objects&quot;: [
      { &quot;type&quot;: &quot;user&quot;, &quot;id&quot;: &quot;120&quot; },
      { &quot;type&quot;: &quot;offer&quot;, &quot;id&quot;: &quot;90&quot; }
      ]
  }
  </code></pre>
  <p>With many of these documents, I'd like to filter those which have a specific related object (e.g. <code>type=user</code> <strong>and</strong> <code>id=120</code>). With the example data above, this should only return the document with id 5. Using simple filters (DQL syntax) as follows does not work:</p>
  <p><code>related_objects.type:user and related_objects.id:120</code></p>
  <p>As this would also match a document 5, as there is a related_object with type user and a related object with id 120, although its not the related user object with id 120, its the related offer.</p>