0

I have CSV file with 1000 rows and 3 columns, as follows:

field1, field2, field3
ABC     A65     ZZZ
...

I want to export its content into the mapping myrecords of the index myindex (I have more mappings in this index):

PUT /myindex
{
  "mappings": {
    "myrecords": { 
      "_all": {
        "enabled": false
      },
      "properties": {
          "field1":  { "type": "keyword" },
          "field2":  { "type": "keyword" },
          "field3":  { "type": "keyword" }
       }
    }
  }
}

Is there any easy way to do it?

UPDATE:

I executed this Logstash config file, but though the size of CSV is small (1000 entries), the process is running eternally. When I execute GET /myindex/myrecords/_search, I see only 1 record all the time.

input {
    file {
        path => ["/usr/develop/data.csv"]
        start_position => beginning
    }
}

filter {  
    csv {
        columns => ["field1","field2","field3"]
        separator => ","
    }
}

output {
    stdout { codec => rubydebug }
    elasticsearch {
        action => "index"
        hosts => ["127.0.0.1:9200"]
        index => "myindex"
        document_type => "myrecords"
        document_id => "%{Id}"  // Here I also tried "%{field1}"
        workers => 1
    }
}
8
  • This answer might help: stackoverflow.com/questions/35433121/… Commented Sep 4, 2017 at 9:09
  • @Val: Thanks. I tried this solution, but the data is not exported (only 1 record). I assume that the problem occurs due to document_id => "%{Id}". I do not have the field Id in my mapping. How can I solve this issue? Please my updated question. Commented Sep 4, 2017 at 11:36
  • Simply remove the document_id setting. Commented Sep 4, 2017 at 11:39
  • 1
    Try to add sincedb_path => "/dev/null" in your file input. Commented Sep 4, 2017 at 11:47
  • 1
    You should consider upvoting the answer I linked to instead. sincedb_path is simply a file that allows Logstash to remember the lines it has already parsed. Setting it to null will make sure that logstash starts at the beginning of the file. Commented Sep 4, 2017 at 11:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.