How does mongodb retrieve the entire document based only on key-value pairs in embedded documents

  mongodb, question
    "_id": {
        "$oid": "50a5e1cd703d7e9c65326bf9"
    "tele": "001-837475"
                "state" : "CA",
                "city" : "LA"

I have a lot of such data stored in mongodb. I have such retrieval requirements. Find all people from California.
In the shell, this is query:


And can return the correct results.

I want to use mongodb-java-builder to retrieve the database. How to write the code?
This problem has puzzled me for a long time.

This is a link to stackoverflow for my question.No one answered either. The answer didn’t work either.

Thank you.

    Mongo db = new Mongo("localhost", 27017);
    DBCollection coll = db.getCollection("collectionname");
    DBObject query = new BasicDBObject("address.state","CA");
    DBCursor cursor = coll.find(query);

It is because I did not have a good look at the documents. I made such a mistake. I shouldn’t. I should reflect on it here.