title: In a mongodb document, how can I set the value of an inner array matched by two variables
body: <p>I have the following data structure in my mongodb (v3.2):</p>
  
  <pre><code>   {
      'user_id':'abc',
      'samples':[
          {'year':2017,'month':9,'value':10},
          {'year':2017,'month':10,'value':0},
          {'year':2017,'month':11,'value':30}
      ]
     }
  </code></pre>
  
  <p>I am trying to modify the items inside the samples array using the following command:</p>
  
  <pre><code>db.COLLECTION.update(
    {'user_id':'abc','samples.year':2017,'samples.month':11},
    {$set:{'samples.$.value':200}})
  </code></pre>
  
  <p>The problem is that this query is updating the first one in the array (month:09) and not the one that I want (month:11). If I remove the year information and use only the month, it works.</p>
  
  <p>Can anyone help me to solve this mystery? At first I was using pymongo, but since it was not working I am using the mongo console directly and still not working.</p>