title: How to import CSV data using Logstash for field type completion in Elasticsearch suggester
body: <p>ElasticSearch Index Creation</p>
  
  <pre><code>curl -XPOST 'http://localhost:9200/music/' -d '{}'
  </code></pre>
  
  <p>Field Mapping</p>
  
  <pre><code>curl -XPUT 'http://localhost:9200/music/_mapping/song' -d '
  {
    "properties": {
      "name" : {
        "type" : "string"
      },
      "suggest": {
        "type" : "completion"
      }
    }
  }'
  </code></pre>
  
  <p>LogStash config file, musicStash.config</p>
  
  <pre><code>input {
      file {
          path =&gt; "pathToCsv"
          start_position =&gt; beginning
      }
  }
  
  filter {  
      csv {
          columns =&gt; ["id", "name", "suggest"]
          separator =&gt; ","
      }
  }
  
  output {
      elasticsearch {
          hosts =&gt; "localhost"
          index =&gt; "music"
          document_id =&gt; "%{id}"
      }
  }
  </code></pre>
  
  <p>Now while executing logstash config file, received following exception in elasticsearch console</p>
  
  <pre><code>failed to put mappings on indices [[music]], type [logs]
  java.lang.IllegalArgumentException: Mapper for [suggest] conflicts with existing mapping in other types:
  [mapper [suggest] cannot be changed from type [completion] to [string]]
  at org.elasticsearch.index.mapper.FieldTypeLookup.checkCompatibility(FieldTypeLookup.java:117)
  </code></pre>
  
  <p>And error received in logstash console,</p>
  
  <pre><code>response=&gt;{"index"=&gt;{"_index"=&gt;"music", "_type"=&gt;"logs", "_id"=&gt;"5", "status"=&gt;400, 
  "error"=&gt;{"type"=&gt;"illegal_argument_exception", 
  "reason"=&gt;"Mapper for [suggest] conflicts with existing mapping in other types:\n[mapper [suggest] cannot be changed from type [completion] to [string]]"}}}, :level=&gt;:warn}
  </code></pre>
  
  <p>So how to achieve elasticsearch auto-complete feature by importing csv file through Logstash.</p>