title: ElasticSearch Sort on nested field across all documents
body: <p>I am trying to figure out if it is possible to sort based on nested field across all documents, for eg. in below JSON, fields is a nested object, what i am looking for is to retrieve all fields.name from all documents and then sort by name field. I know i can do this using inner hit query if it is part of single document. </p>
  
  <p>The other option is to retrieve all documents and then do sorting on front end/middle tier which is not a good option. </p>
  
  <pre><code>[ {
            "id": "42ddf6e1-23f5-4aed-9d3a-1ba3ac3677b1",
            "fields": [
              {
                "name": "asofheading"
              },
              {
                "name": "SEC_TYPE"
              }
            ],
  },
  {
            "id": "7579928e-2196-4f7d-aaf8-4bfe9e67b330",
            "fields": [
              {
                "name": "asofheading"
              },
              {
                "name": "SEC_TYPE"
              },
              {
                "name": "CUSIP"
              }
            ]
   },
          {
            "id": "3a0940c1-7495-400c-a204-cd9bc6966fae",
            "fields": [
              {
                "name": "AsofHeading"
              },
              {
                "name": "SECT_PROFILE"
              },
              {
                "name": "SECT_PROFILESP"
              }
          },
  
  ]
  </code></pre>
  
  <p>I want to extract only field name from all documents and then sort by field name</p>