title: Elasticsearch stored_fields order
body: <p>I've run into an order peculiarity with the stored_fields of Elasticsearch. Basically, the stored_fields are not retrieved in the order I specify in the request. As an example, I create the following index with three fields and request the fields in a specific order:</p>
  <pre><code>PUT /test_field_order
  {
    &quot;mappings&quot;: {
      &quot;properties&quot;: {
        &quot;field1&quot;: { &quot;type&quot;: &quot;text&quot;, &quot;store&quot;: true},
        &quot;field2&quot;: { &quot;type&quot;: &quot;text&quot;, &quot;store&quot;: true},
        &quot;field3&quot;: { &quot;type&quot;: &quot;text&quot;, &quot;store&quot;: true}
      }
    }
  }
  
  PUT /test_field_order/_doc/1
  {
    &quot;field1&quot;: &quot;field1&quot;,
    &quot;field2&quot;: &quot;field2&quot;,
    &quot;field3&quot;: &quot;field3&quot;
  }
  
  GET test_field_order/_search
  {
    &quot;query&quot;: {
      &quot;match&quot;: {
        &quot;_id&quot;: 1
      }
    },
    &quot;stored_fields&quot;: [&quot;field3&quot;, &quot;field1&quot;, &quot;field2&quot;]
  }
  </code></pre>
  <p>After running this on Kibana, the following is retrieved:</p>
  <pre><code>{
    &quot;took&quot; : 1,
    &quot;timed_out&quot; : false,
    &quot;_shards&quot; : {
      &quot;total&quot; : 1,
      &quot;successful&quot; : 1,
      &quot;skipped&quot; : 0,
      &quot;failed&quot; : 0
    },
    &quot;hits&quot; : {
      &quot;total&quot; : {
        &quot;value&quot; : 1,
        &quot;relation&quot; : &quot;eq&quot;
      },
      &quot;max_score&quot; : 1.0,
      &quot;hits&quot; : [
        {
          &quot;_index&quot; : &quot;test_field_order&quot;,
          &quot;_type&quot; : &quot;_doc&quot;,
          &quot;_id&quot; : &quot;1&quot;,
          &quot;_score&quot; : 1.0,
          &quot;fields&quot; : {
            &quot;field1&quot; : [
              &quot;field1&quot;
            ],
            &quot;field3&quot; : [
              &quot;field3&quot;
            ],
            &quot;field2&quot; : [
              &quot;field2&quot;
            ]
          }
        }
      ]
    }
  }
  </code></pre>
  <p>As you can see, the stored_fields are retrieved in the order [field1, field3, field2]. This doesn't match with the order of the request [field3, field1, field2]. Furthermore, it doesn't match with the index order [field1, field2, field3] either. How is the retrieve order determined? Does Elasticsearch guarantee that the order of stored_fields match the order of fields in the request? I couldn't find any specification about the ordering.</p>