title: How to project nested documents along side properties in the root document?
body: <p>I am attempting to return a projection of a nested document and some properties from the root document also. I would like to do this within the query if at all possible.</p>
  <p>For example, I have an index <code>cities</code> where and the initial dataset:</p>
  <pre class="lang-json prettyprint-override"><code>[
      {
          _id: &quot;1&quot;,
          city: &quot;New York&quot;
          state:&quot;NY&quot;
          users: [ 
           {
              firstName: &quot;John&quot;,
              lastname: &quot;Peters&quot;,
              birthYear: 1985
           }, {
              firstName: &quot;Raul&quot;,
              lastname: &quot;Other&quot;,
              birthYear: 1986
           }, {
              firstName: &quot;Paul&quot;,
              lastname: &quot;Ray&quot;,
              birthYear: 1997
           }
          ]       
      },
      {
          _id: &quot;2&quot;,
          city: &quot;Hackensack&quot;,
          state: &quot;NJ&quot;
          users: [ 
           {
              firstName: &quot;Joe&quot;,
              lastname: &quot;Anders&quot;,
              birthYear: 1988
           }
          ]
      }, 
      {
          _id: &quot;3&quot;,
          city: &quot;Albany&quot;
          state:&quot;NY&quot;
          users: [ 
           {
              firstName: &quot;Zoy&quot;,
              lastname: &quot;Bat&quot;,
              birthYear: 1984
           }, {
              firstName: &quot;Ana&quot;,
              lastname: &quot;Lily&quot;,
              birthYear: 1999
           }
          ]        
      }
  ]
  
  </code></pre>
  <p><code>users</code> is of type <code>nested</code>. (S/n: I think this is for the best currently because I would like to possibly filter on one of the properties, but I am willing to change this if need be.)</p>
  <p>I would like to do a query for users in the <code>state</code> of <code>NY</code> ordered by <code>birthYear</code>, and what I would like Elasticsearch to return is something like:</p>
  <pre class="lang-json prettyprint-override"><code>[
    {
      city: &quot;Albany&quot;
      firstName: &quot;Zoy&quot;,
      lastname: &quot;Bat&quot;,
      birthYear: 1984
    }, {
      city: &quot;New York&quot;
      firstName: &quot;John&quot;,
      lastname: &quot;Peters&quot;,
      birthYear: 1985
    }, { 
      city: &quot;New York&quot;
      firstName: &quot;Raul&quot;,
      lastname: &quot;Other&quot;,
      birthYear: 1986
    }, {
      city: &quot;New York&quot;
      firstName: &quot;Paul&quot;,
      lastname: &quot;Ray&quot;,
      birthYear: 1997
    }, {
      city: &quot;Albany&quot;
      firstName: &quot;Ana&quot;,
      lastname: &quot;Lily&quot;,
      birthYear: 1999
    }        
  ]
  </code></pre>
  <p>This feels like something that should be possible during query time but I have not been able to find the appropriate functionality.</p>