title: Creating Indexes with mapping in ES 6.5 on Java REST Client [6.5] API
body: <p>I am new to elastic search and trying to integrate an autocomplete feature for an app by following the article <a href="https://www.elastic.co/blog/you-complete-me" rel="nofollow noreferrer">https://www.elastic.co/blog/you-complete-me</a>.</p>
  
  <p>I have followed the below approach to do the same.</p>
  
  <p>Event class</p>
  
  <pre><code>       public class Event {
  
          private Long eventId;
          private Long catalogId;
          private Long orgId;
          private String orgName;
          private String catalogName;
          private String name;
          private String eventStatus;
  .....
      }
  </code></pre>
  
  <p>An objectmapper is used to convert the event object to json string. Here is the code to insert the document</p>
  
  <pre><code>public String createEventDocument(Event document) throws Exception {
      IndexRequest indexRequest = new IndexRequest(INDEX, TYPE, document.idAsString())
              .source(convertEventDocumentToMap(document));
      //create mapping with a complete field
      IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
      return indexResponse.getResult().name();
  }
  </code></pre>
  
  <p>Convert code</p>
  
  <pre><code>private Map&lt;String, Object&gt; convertEventDocumentToMap(Event evt) {
      return objectMapper.convertValue(evt, Map.class);
  }
  </code></pre>
  
  <p>I would like to create an index, and setup the completion suggester for the name_suggest field. How can I achieve the same ?</p>
  
  <p>Any help is appreciated</p>