title: Elasticsearch AND Parens
body: <p>I'm attempting to do the following with the query dsl but I'll express it as SQL:</p>
  
  <pre><code>(matrices.matrix = 'Matrix1' AND matrices.count = 1) AND (matrices.matrix = 'Matrix2' AND matrices.count &gt;= 0)
  </code></pre>
  
  <p>So, I need to get docs that have both of these nested docs with these values.</p>
  
  <p>This is the nested document it sits on the _source level</p>
  
  <pre><code>"matrices": [
                {
                   "terms": [],
                   "count": 0,
                   "matrix": "none"
                },
                {
                   "terms": [
                      "greater"
                   ],
                   "count": 1,
                   "matrix": "Matrix1"
                }
             ]
  </code></pre>
  
  <p>And here is the mapping for the sub-doc:</p>
  
  <pre><code>"matrices": {
                "type": "nested",
                "include_in_parent": true,
                "properties": {
                   "count": {
                      "type": "long"
                   },
                   "matrix": {
                      "type": "string"
                   },
                   "terms": {
                      "type": "string"
                   }
                }
             }
  </code></pre>
  
  <p>So, I need to generate a query that will allow me to get docs that match both (matrix = 'none' &amp;&amp; count=0) &amp;&amp; (matrix = 'Matrix' &amp;&amp; count = 1)</p>
  
  <p>Thanks, </p>