title: How to execute queries with both AND and OR clauses in MongoDB with Java?
body: <p>I want to execute query in MongoDB 3.2 with Java Driver 3.2, which contains both <code>$and</code> and <code>$or</code> clauses at the same time.</p>
  
  <p>With the <a href="https://stackoverflow.com/a/10621210/462347">reference</a>, I tried the following approach:</p>
  
  <pre><code>List&lt;Document&gt; criteria1 = new ArrayList&lt;&gt;();
  List&lt;Document&gt; criteria2 = new ArrayList&lt;&gt;();
  
  criteria1.add(new Document("fetchStatus", new Document("$gte", FetchStatus.PROCESSED_NLP.getID())));
  criteria1.add(new Document("fetchStatus", new Document("$lte", fetchStatusParam)));
  criteria1.add(new Document("episodeID", new Document("$in", episodeIDs)));
  
  criteria2.add(new Document("fetchStatus", new Document("$eq", PROCESSED_FETCH.getID())));
  criteria2.add(new Document("isFullTextRet", new Document("$eq", false)));
  
  BasicDBList or = new BasicDBList();
  or.add(criteria1);
  or.add(criteria2);
  
  DBObject query = new BasicDBObject("$or", or);
  ArrayList&lt;Document&gt; results = dbC_Coll.find(query).into(new ArrayList&lt;&gt;());
  </code></pre>
  
  <p>Where the <code>criteria1</code> and <code>criteria2</code> should be connected with <code>$or</code> while within <code>criteria1</code> clause the <code>$and</code> should be applied.</p>
  
  <p>The problem is that in MongoDB Java Driver 3.2 there is such no method and I get the <code>Cannot resolve method find(com.mongodb.DBObject)</code> error.</p>
  
  <p><strong>My question:</strong><br>
  How can I compose a query such as <code>(A &amp;&amp; B) || (X &amp;&amp; Y)</code> in MongoDB Java Driver 3.2?</p>