title: How to add bool query inside a should/must method in java api?
body: <p>I have a query like this in elasticsearch:</p>
  
  <pre><code>"query": {
          "bool": {
              "should": [
               {"bool": {
                     "must": [
                         {"term": {
                             "field1": "value1"
                         }},
                         {"term": {
                             "field2": "value2"
                         }}
                 ]}
                 },
                 {"bool": {
                     "should": [
                         {"term":{                  
                             "field1": "value3"
                         }}
                 ]}       
                 }
              ]
          }
      }
  </code></pre>
  
  <p>Basically, it's <code>((field1 == value1 AND field2 == value2) OR (field1 == value3))</code>. But I have not found a way to implement that in the Java API. I have tried something like this:</p>
  
  <pre><code> BoolQueryBuilder filter = new BoolQueryBuilder()
                      .should(QueryBuilders.termQuery(field1, value3)
                      .should(QueryBuilders.boolQuery().must(QueryBuilders.termQuery(field1, value1))
                               .must(QueryBuilders.termQuery(field2, value2)))
                      );
  </code></pre>
  
  <p>but the <code>should</code> method doesn't take a <code>BoolQueryBuilder</code>. What's the correct way to do it? Thank you very much.</p>