title: Mongodb query for nested document in java
body: <p>I am new to Mongodb. I have the following dataset in mongodb.</p>
  
  <pre><code>{
  "_id": {
      "$oid": "563644f44b17ca12886440a9"
  },
  "data": [
      {
          "uid": 1,
          "character": " ",
          "unicode": 32,
          "color": -7309587
      },
      {
          "uid": 2,
          "character": "!",
          "unicode": 33,
          "color": -8911704
      },
      {
          "uid": 3,
          "character": "\"",
          "unicode": 34,
          "color": -1778539
      }
  </code></pre>
  
  <p>I am trying to retrieve the color from this field using the _id and character. I am not able to execute the query. </p>
  
  <p>This is what I tried.</p>
  
  <pre><code>DBObject clause1 = new BasicDBObject("_id",new ObjectId(KEY1));  
                  DBObject clause2 = new BasicDBObject("data.character",text[i]);    
                  BasicDBList or = new BasicDBList();
                  or.add(clause1);
                  or.add(clause2);
                  DBObject query = new BasicDBObject("$and", or);
  </code></pre>
  
  <p>Also I am having a lot of issues in finding ways to query in mongodb-java for the 3.0.0+ api. Could someone please help?</p>