title: Why does my sorted nested ElasticSearch with custom analyzer using NEST return invalid result?
body: <p>Using elasticSearch v6.2.4 I want to sort my results based on user selection in the HMI.</p>
  
  <p>This is successful for most of the elements in my SearchableSituation but not for the member InvolvedVessels.</p>
  
  <p>I'm quite new to ES, and having read around I'm feeling a bit lost with all the possible variants of Querying and sorting etc..</p>
  
  <p>Short version of the class:</p>
  
  <pre><code>public class SearchableSituation : IEquatable&lt;SearchableSituation&gt;
  {
      //Other members
      public IEnumerable&lt;SearchableInvolvedVessel&gt; InvolvedVessels { get; set; }
  }
  </code></pre>
  
  <p>The mapping of the field is done here:</p>
  
  <pre><code>    private static TypeMappingDescriptor&lt;SearchableSituation&gt; ConfigureNestedSearchableSituation(TypeMappingDescriptor&lt;SearchableSituation&gt; mapping)
  {
      return mapping
          .AutoMap()
          .Properties(ps =&gt; ps
              .Text(t =&gt; t
                  .Name(n =&gt; n.SituationId)
                  .Analyzer("keyword"))
              .Nested&lt;SearchableInvolvedVessel&gt;(ConfigureSearchableInvolvedVessel); // More Nested items in actual code removed for simplicity
   }
  
  private static NestedPropertyDescriptor&lt;SearchableSituation, SearchableInvolvedVessel&gt; ConfigureSearchableInvolvedVessel(NestedPropertyDescriptor&lt;SearchableSituation, SearchableInvolvedVessel&gt; nestedPropertyDescriptor)
  {
      return nestedPropertyDescriptor
          .AutoMap()
          .Properties(np =&gt; np
               .Text(t =&gt; t
                  .Name(nn =&gt; nn.VesselName)
                  .Fields(f =&gt; f
                      .Text(tk =&gt; tk
                          .Name("singleTerm") //adding sub-field with keyword analyzer to index 'Name' property to include single term search when using phrase_prefix queries.
                          .Analyzer("keywordWithCaseIgnore"))))
              .Text(t =&gt; t
                  .Name(nn =&gt; nn.VesselId)
                  .Analyzer("keyword")
              )
          )
          .Name(nn =&gt; nn.InvolvedVessels);
  }
  </code></pre>
  
  <p>With the index defined as (removed some items to reduce size here):</p>
  
  <pre><code>{
  "situationsindex": {
      "aliases": {},
      "mappings": {
          "searchablesituation": {
              "properties": {
                  "involvedVessels": {
                      "type": "nested",
                      "properties": {
                          "callSign": {
                              "type": "text",
                              "fields": {
                                  "keyword": {
                                      "type": "keyword",
                                      "ignore_above": 256
                                  }
                              }
                          },
                          "isRiskRole": {
                              "type": "boolean"
                          },
                          "vesselName": {
                              "type": "text",
                              "fields": {
                                  "singleTerm": {
                                      "type": "text",
                                      "analyzer": "keywordWithCaseIgnore"
                                  }
                              }
                          }
                      }
                  },
                  "situationId": {
                      "type": "text",
                      "analyzer": "keyword"
                  },
                  "status": {
                      "type": "integer"
                  },                   
              }
          }
      },
      "settings": {
          "index": {
              "number_of_shards": "5",
              "provided_name": "situationsindex",
              "creation_date": "1577957440559",
              "analysis": {
                  "normalizer": {
                      "lowercaseNormalizer": {
                          "filter": [
                              "lowercase"
                          ],
                          "type": "custom"
                      }
                  },
                  "analyzer": {
                      "keywordWithCaseIgnore": {
                          "filter": [
                              "lowercase"
                          ],
                          "type": "custom",
                          "tokenizer": "keyword"
                      }
                  }
              },
              "number_of_replicas": "1",
              "uuid": "-UoM84BxQwiUdT6QLL04Eg",
              "version": {
                  "created": "6020499"
              }
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I'm trying to build my query as such:</p>
  
  <pre><code>var sortedResult = await _client.SearchAsync&lt;SearchableSituation&gt;(s =&gt; s
  .Index(_situationIndexer.IndexName)
  .From(message.Query.SearchResultsFrom)
  .Size(message.Query.SearchResultsSize)
  .Sort(sort =&gt; sort.Ascending(f =&gt; f.Status)
      .Field(x =&gt; x.Nested(y =&gt; y.Path(p =&gt; p.InvolvedVessels))
          .Field(v =&gt; v.InvolvedVessels.First().VesselName.Suffix("keyword"))
          .Field("name.singleTerm")
          .Order(sortOrder)))
  .Query(q =&gt; q
      .Bool(m =&gt; m
          .Must(queries))));
  </code></pre>
  
  <p>Where .Query is an optional filter which by default is empty (returning all elements). </p>
  
  <p>Returns:</p>
  
  <pre><code>Invalid NEST response built from a unsuccessful low level call on POST: /situationsindex/searchablesituation/_search?typed_keys=true # Audit trail of this API call: - [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.0030001 # OriginalException: System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Elasticsearch.Net.HttpConnection.d__14`1.MoveNext() in C:\Users\russ\source\elasticsearch-net-master\src\Elasticsearch.Net\Connection\HttpConnection.cs:line 242 # Request: # Response: 
  </code></pre>
  
  <p>Having a tried a number of variants of Path, Field and Suffix options without success I'm beginng to feel a bit stuck.</p>
  
  <p>Can anyone guide me on where I'm going wrong?</p>