title: Elasticsearch - Autocomplete with NEST
body: <p>I'm trying to do autocomplete with the NEST client.</p>
  
  <p>The code looks as follows:</p>
  
  <p>Poco (condensed):</p>
  
  <pre><code>public class Course
  {
      [ElasticProperty(Name="id")]
      public int ID { get; set; }
      public string Name { get; set; }   
      [ElasticProperty(Type = FieldType.Completion)]
      public CompletionField Suggest { get; set; }
  
      public Course(sm.Models.Course c)
      {
          if (c != null)
          {
              this.ID = c.ID;
              this.Name = c.Name;
              this.Suggest = new CompletionField
              {
                  Input = new List&lt;string&gt;(this.Name.Split(' ')) { this.Name },
                  Output = this.Name,
                  Payload = new
                  {
                      id = this.Name
                  },
                  Weight = 1
              };
          }
      }
  }   
  </code></pre>
  
  <p>Indexing:</p>
  
  <pre><code>Client.CreateIndex("myindex", c =&gt; c
              .NumberOfReplicas(1)
              .NumberOfShards(5)
              .Settings(s =&gt; s
                  .Add("merge.policy.merge_factor", "10")
                  .Add("search.slowlog.threshold.fetch.warn", "1s")
              )
              .AddMapping&lt;Course&gt;(m =&gt; m.MapFromAttributes()
                  .Properties(props =&gt; props
                      .Completion(s=&gt;s
                          .Name(p=&gt;p.Suggest)
                          .IndexAnalyzer("simple")
                          .SearchAnalyzer("simple")
                          .MaxInputLength(20)
                          .Payloads()
                          .PreservePositionIncrements()
                          .PreserveSeparators()
                      )
                  )                
              ));
  </code></pre>
  
  <p>My suggest query:</p>
  
  <pre><code>GET _suggest
  {
    "course-suggest": {
     "text": "Nothilfe",
     "completion": {
       "field": "suggest",
       "size": 10
     }
    }
  }
  </code></pre>
  
  <p>Which results in this error:</p>
  
  <pre><code>    "failures": [
           {
              "shard": 1,
              "index": "myindex",
              "status": "INTERNAL_SERVER_ERROR",
              "reason": {
                 "type": "exception",
                 "reason": "failed to execute suggest",
                 "caused_by": {
                    "type": "exception",
                    "reason": "Field [suggest] is not a completion suggest field"
                 }
              }
           }
  </code></pre>
  
  <p>Why is my suggest field not recognized as a completion field?</p>
  
  <p>GET _mapping/course </p>
  
  <pre><code>"suggest": {
    "properties": {
       "input": {
          "type": "string"
       },
       "output": {
          "type": "string"
       },
       "payload": {
          "properties": {
             "id": {
                "type": "string"
             }
          }
       },
       "weight": {
          "type": "long"
       }
    }
  </code></pre>