Embedded document filtration in mongodb
<p>{</p>

<pre><code>"_id" : ObjectId("57f5ee94536d1a50ed3337c6"),
"details" : [
    {
        "status" : NumberLong(0),
        "batch_id" : null,
        "applied_date" : NumberLong(1470283450),
        "call_letter" : 72,
        "fid" : "3273681"
    },
    {
        "status" : NumberLong(0),
        "batch_id" : null,
        "applied_date" : NumberLong(1470205742),
        "call_letter" : 72,
        "fid" : "3308438"
    },
    {
        "status" : NumberLong(0),
        "batch_id" : null,
        "applied_date" : NumberLong(1470396778),
        "call_letter" : 72,
        "fid" : "3539451"
    },
    {
        "status" : NumberLong(0),
        "batch_id" : null,
        "applied_date" : NumberLong(1470283450),
        "call_letter" : 75,
        "fid" : "3273681"
    },
    {
        "status" : NumberLong(0),
        "batch_id" : null,
        "applied_date" : NumberLong(1470205742),
        "call_letter" : 75,
        "fid" : "3308438"
    },
    {
        "status" : NumberLong(0),
        "batch_id" : null,
        "applied_date" : NumberLong(1470396778),
        "call_letter" : 75,
        "fid" : "3539451"
    }
],
"job_id" : "92854"
}
</code></pre>

<p>This is my document format of <code>mongodb</code>.</p>

<p>I need to select all <strong>fid</strong> based on <strong>call_letter = 75</strong> for particular <code>job_id</code> and <code>list of job ids</code> (using pymondo)</p>

<p>How to filter data based on this conditions? please help me.</p>

<p>As I am new to mongoDB, I would like to get the answer for my particular query  </p>

<p>Try using and aggregate query like below</p>

<pre><code>db.jobs.aggregate([{"$match":{"job_id" : "92854"}},
              {"$unwind":"$details"},
              {"$match":{call_letter"" : "75"}}])
</code></pre>

<p>Add '$project' and '$group' to the pipeline to format your output as required (use '$push' to make it a list).</p>

python