I have the followng json file
{
  "movies": [{
    "title" : "Star Wars: Episode I - The Phantom Menace",
    "episode_number" : "1",
    "main_characters" : ["Qui-Gon Jinn", "Obi-Wan Kenobi"],
    "description" : "The evil Trade Federation, led by Nute Gunray is planning to take over the peaceful world of Naboo. ",
    "poster" : "star_wars_episode_1_poster.png",
    "hero_image" : "star_wars_episode_1_hero.jpg"
  },
  {
    "title" : "Star Wars: Episode II - Attack of the Clones",
    "episode_number" : "2",
    "main_characters" : ["Obi-Wan Kenobi", "Anakin Skywalker"],
    "description" : "Ten years after the 'Phantom Menace' threatened the planet Naboo, Padmé Amidala is now a Senator representing her homeworld.",
    "poster" : "star_wars_episode_2_poster.png",
    "hero_image" : "star_wars_episode_2_hero.jpg"
  }
]
}
The collection name is fruits
I am trying to extract only the data for episode_number = 2. I have tried following queries
db.fruits.find({"movies": {$elemMatch:{"episode_number": "2"}}}).pretty();
which returns the entire document instead of just the data for episode_number 2.
and
db.fruits.find({"movies.episode_number": "2"}}}).pretty();
which also returns the entire document including that for episode_number 1
I am trying to figure out how to query this document so that only the data for episode_number = 2 is returned.
Please help.
 
     
    