title: NEST / Elastic Search Auto-Completion 'Field [suggest] is not a completion suggest field'
body: <p>In between projects, started to play around with Elastic Search and NEST in preparation for some auto-completion features coming up.</p>
  
  <p>I followed examples here and in the various docs ... and it <em>seems</em> like what I have should work. There must be some subtle difference with what i am doing.</p>
  
  <p>This is the object that represents my document.</p>
  
  <pre><code>    [ElasticType(IdProperty="KeyInstn")]
  public class Instn
  {
      [ElasticProperty(Name = "keyinstn", Index = FieldIndexOption.Analyzed, Type = FieldType.Integer)]
      public int KeyInstn { get; set; }
      public string Type { get; set; }
  
      [ElasticProperty(Name = "name", Index = FieldIndexOption.Analyzed, Type = FieldType.String)]
      public string Name { get; set; }
  
      [ElasticProperty(Name = "ticker", Index = FieldIndexOption.Analyzed, Type = FieldType.String)]
      public string Ticker { get; set; }
  
      [ElasticProperty(Name = "street", Index = FieldIndexOption.Analyzed, Type = FieldType.String)]
      public string Street { get; set; }
  
      [ElasticProperty(Name = "city", Index = FieldIndexOption.Analyzed, Type = FieldType.String)]
      public string City { get; set; }
  
      [ElasticProperty(Name = "state", Index = FieldIndexOption.Analyzed, Type = FieldType.String)]
      public string State { get; set; }
  
      [ElasticProperty(Name = "zip", Index = FieldIndexOption.Analyzed, Type = FieldType.String)]
      public string Zip { get; set; }
  
      [ElasticProperty(Name = "country", Index = FieldIndexOption.Analyzed, Type = FieldType.String)]
      public string Country { get; set; }
  
      [ElasticProperty(Name = "suggest", Type = FieldType.Completion)]
      public CompletionField Suggest { get; set; }
  }
  </code></pre>
  
  <p>This is the code that I use to create my index:</p>
  
  <pre><code>            var index = client.CreateIndex("snl", 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;Instn&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>I am populating my documents using IndexMany in batches of 1000 documents.</p>
  
  <p>I then perform my query:</p>
  
  <pre><code>            var suggestResponse = this._client.Suggest&lt;Instn&gt;(s =&gt; s
          .Index("snl")
          .Completion("suggest", c =&gt; c
              .Text(this.AutoCompleteText.Text)
              .OnField("suggest")));
  </code></pre>
  
  <p>The error I receive is:</p>
  
  <p>Field [suggest] is not a completion suggest field</p>
  
  <p>Using SENSE, I pulls the mappings and notice that "suggest" doesn't have a type. The examples I followed indicate that the type should be 'completion.:'</p>
  
  <p><a href="https://stackoverflow.com/questions/33677298/elasticsearch-autocomplete-with-nest">Elasticsearch - Autocomplete with NEST</a></p>
  
  <pre><code>    {
     "snl": {
        "mappings": {
           "instn": {
              "properties": {
                 "city": {
                    "type": "string"
                 },
                 "country": {
                    "type": "string"
                 },
                 "keyinstn": {
                    "type": "long"
                 },
                 "name": {
                    "type": "string"
                 },
                 "state": {
                    "type": "string"
                 },
                 "suggest": {
                    "properties": {
                       "input": {
                          "type": "string"
                       },
                       "output": {
                          "type": "string"
                       },
                       "payload": {
                          "type": "long"
                       },
                       "weight": {
                          "type": "double"
                       }
                    }
                 },
                 "type": {
                    "type": "string"
                 },
                 "zip": {
                    "type": "string"
                 }
              }
           }
        }
     }
  }
  </code></pre>
  
  <p>In place of the CompletionObject I created myself, I also tried the intrinsic object, "SuggestField."</p>
  
  <p>If anyone could point me in the right direction of what I am doing wrong, I'd appreciate it. FWIW "normal" searches work fine and return appropriate results.</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE 1/26/2016</strong></p>
  
  <p>So, managed to get an index created that looks "better" ... I was able to get around the new error "analyzer on completion field must be set when search_analyzer is set" by omitting the search analyzer during creation and now my index looks like this:</p>
  
  <pre><code>        {
     "snl": {
        "aliases": {},
        "mappings": {
           "instn": {
              "properties": {
                 "city": {
                    "type": "string"
                 },
                 "country": {
                    "type": "string"
                 },
                 "keyinstn": {
                    "type": "long"
                 },
                 "name": {
                    "type": "string"
                 },
                 "state": {
                    "type": "string"
                 },
                 "suggest": {
                    "properties": {
                       "completion": {
                          "properties": {
                             "field": {
                                "type": "string"
                             }
                          }
                       },
                       "input": {
                          "type": "string"
                       },
                       "output": {
                          "type": "string"
                       },
                       "payload": {
                          "type": "long"
                       },
                       "text": {
                          "type": "string"
                       },
                       "weight": {
                          "type": "double"
                       }
                    }
                 },
                 "type": {
                    "type": "string"
                 },
                 "zip": {
                    "type": "string"
                 }
              }
           }
        },
        "settings": {
           "index": {
              "creation_date": "1453835225862",
              "number_of_shards": "5",
              "number_of_replicas": "1",
              "uuid": "90QKK1OyRMKtwcyjAwPElA",
              "version": {
                 "created": "2010199"
              }
           }
        },
        "warmers": {}
     }
  }
  </code></pre>
  
  <p>However, no completion searches return any results. Is it because the search analyzer omission? If so, how do I get around the "analyzer on completion field must be set when search_analyzer is set" error?</p>