title: Mongodb aggregation function in Amazon Document DB
body: <p>I have the following document in the mongodb running on amazon document DB, which is mongodb 3.6</p>
  <pre><code>{&quot;item&quot;:&quot;journal&quot;, &quot;instock&quot;:[{&quot;warehouse&quot;:&quot;A&quot;, &quot;qty&quot;:[2,4,5] }, {&quot;warehouse&quot;:&quot;C&quot;, &quot;qty&quot;:[8,5,2] }, {&quot;warehouse&quot;:&quot;F&quot;, &quot;qty&quot;:[3] }, {&quot;warehouse&quot;:&quot;K&quot;, &quot;qty&quot;:[2,4,8] }, {&quot;warehouse&quot;:&quot;P&quot;, &quot;qty&quot;:[3,7,9] } ] }
  </code></pre>
  <p>With this data I simply want to extract instock objects having a qty 5.
  The query I'm running on my local mongodb(4.2) is the following:</p>
  <pre><code>db.inventory.aggregate({$match:{&quot;item&quot;: &quot;journal&quot;}}, {$project:{instock: {$filter: {input: &quot;$instock&quot;, cond: {$in: [5, &quot;$$this.qty&quot;] } } } }})
  </code></pre>
  <p>which gives the expected result:</p>
  <pre><code>{ &quot;_id&quot; : ObjectId(&quot;5f59a6bd85a366711c35fc7b&quot;), &quot;instock&quot; : [ { &quot;warehouse&quot; : &quot;A&quot;, &quot;qty&quot; : [ 2, 4, 5 ] }, { &quot;warehouse&quot; : &quot;C&quot;, &quot;qty&quot; : [ 8, 5, 2 ] } ] }
  </code></pre>
  <p>But the problem is when I ran the same query in DocumentDB, if gives an error:
  &quot;errmsg&quot; : &quot;$in requires an array as a second argument, found: string&quot;,</p>
  <p>As per the mongodb documentation, $filter operation is there since version 3.2. So I'm not quite sure what's the issue here. Any ideas please?</p>