0

I am new to MongoDB. And now i got a puzzle: say i've got a query workable in mongo console

{
    "_id": {
       "$oid": "50a5e1cd703d7e9c65326bf9"
    },
    "people":{
                "name":"arthur",
                "tele": "001-837475"
                "address":{
                             "country":"us",
                             "state" : "CA",
                             "city" : "LA"
                          }
             }
}

I've got pretty many record like this. & I want to query for all people who come from CA. The query below works well in mongo shell

 db.test.find({"people.address.state":"CA"})

But I must do the query in Java.

PS: I don't want to use other opensource packages. just the mongodb-java-driver would be delightful.

Thanks.

user1570120
  • 87
  • 1
  • 6

1 Answers1

1

There should not be any problem, you can use the query in the exact same way:

DBObject query = new BasicDBObject("people.address.state", "CA");
test.find(query);
Thilo
  • 257,207
  • 101
  • 511
  • 656