title: In Elasticsearch, how can I get the whole of a nested field returned without the whole object?
body: <p>I have a mapping in which I have a nested type, with the nested object usually comprising more than one object, so it is an array if the whole main object is retrieved. Using the "fields" part of a search request I can get fields of the main object, and fields from the nested objects (as an array except when there is only one), but not, apparently, the whole nested object array. Is there any way to do this other than getting the whole object (omitting fields)?</p>
  
  <p>For example:</p>
  
  <p><code>{
       "properties: {
       "f1": {"type": "string"},
       "f2": {"type": "string"},
       ...
       "n": {
           "type": "nested",
           "properties": {
              "n1": {"type": "string"},
              "n2": {"type": "string"},
              ...
            }
        }
      }
  }</code></p>
  
  <p>Typically, n will be an array, but n1 may not be set for all entries</p>
  
  <p>This query works, but because of missing n1's in some of the objects in the array, isn't helpful:</p>
  
  <p><code>{"query": {"nested": {"path": "n", "query": {"match": {"n.n1","something"}}}},
    "fields": ["f1", "n.n1"]}</code></p>
  
  <p>This doesn't ("field [n] isn't a leaf field"), but is what I really want:</p>
  
  <p><code>{"query": {"nested": {"path": "n", "query": {"match": {"n.n1","something"}}}},
    "fields": ["f1", "n"]}</code></p>
  
  <p>But this does, at the expense of retrieving the whole object including (array of) n:</p>
  
  <p><code>{"query": {"nested": {"path": "n", "query": {"match": {"n.n1","something"}}}}}</code></p>
  
  <p>Is there some query syntax I'm missing that would give me the whole array n (and also at least one of the string fields in the main object) when a field in one of the n's matches, without getting the whole matching object?</p>