title: Cosmos DB : Find the index of an item in an array
body: <p>I want to find the index number of all items in a nested array in Cosmos DB :</p>
  <p>Data :</p>
  <pre><code>{
  &quot;id&quot;:&quot;MyId&quot;,
  &quot;items&quot; : [
  {&quot;id&quot;: &quot;Item1&quot;},
  {&quot;id&quot; : &quot;Item2&quot;}
  ]
  }
  </code></pre>
  <p>Query :</p>
  <pre><code>SELECT f.id, index : ** How to get the index of items ? ** 
  
  FROM root JOIN f IN root[&quot;items&quot;] 
  
  WHERE (IS_DEFINED(root[&quot;items&quot;]) AND (root[&quot;id&quot;] = &quot;MyId&quot;))
  </code></pre>
  <p>I would like a result like this  :</p>
  <pre><code>[
  
  {&quot;id&quot;: &quot;item1&quot;, &quot;index&quot;: 0},
  
  {&quot;id&quot;: &quot;item2&quot;, &quot;index&quot; : 1}
  
  ]
  </code></pre>
  <p>Thx</p>