title: How to add an unanalyzed text keyword for sorting in elasticsearch with NEST?
body: <p>I'm using the NEST client in C# to interact with my elasticsearch cluster.</p>
  
  <p>I'm trying to sort based on a string value. But per <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html" rel="nofollow noreferrer">this</a>, I can't do that because the field is a text field.</p>
  
  <p>So I want to add a keyword field and sort based on that for better performance. Something like this:</p>
  
  <pre><code>{
    "mappings": {
      "my_type": {
        "properties": {
          "my_field": { 
            "type": "text",
            "fields": {
              "keyword": { 
                "type": "keyword"
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>But I'm not sure how to best translate that to the NEST client and then how to sort based on <code>my_field.keyword</code>.</p>
  
  <p>I have this as my mapping, but since I'm not sure what the sort clause looks like, I'm not sure how to test it.</p>
  
  <pre><code>.Mappings(m =&gt; m
      .Map&lt;Product&gt;(mm =&gt; mm
          .Properties(p =&gt; p
              .Text(t =&gt; t
                  .Name(n =&gt; n.ProductName)
                  .Analyzer("custom")
                  .Fields(f =&gt; f
                      .Keyword(k =&gt; k)
                  )
              )
          )
      )
  )
  </code></pre>
  
  <p>I've been trying to dig through the NEST documentation, but this more edge functionality has been harder to find.</p>