import csv into elasticsearch

后端 未结 2 1716
后悔当初
后悔当初 2020-12-25 12:46

I\'m doing \"elastic search getting started\" tutorial. Unfortunatelly this tutorial doesn\'t cover first step which is importing csv database into elasticsearc

相关标签:
2条回答
  • 2020-12-25 13:24

    I'm the author of moshe/elasticsearch_loader
    I wrote ESL for this exact problem.
    You can download it with pip:

    pip install elasticsearch-loader
    

    And then you will be able to load csv files into elasticsearch by issuing:

    elasticsearch_loader --index incidents --type incident csv file1.csv
    

    Additionally, you can use custom id file by adding --id-field=document_id to the command line

    0 讨论(0)
  • 2020-12-25 13:31

    Good job, you're almost there, you're only missing the document ID. You need to modify your elasticsearch output like this:

    elasticsearch {
        action => "index"
        hosts => ["127.0.0.1:9200"]
        index => "simpsons"
        document_type => "episode"
        document_id => "%{id}"             <---- add this line
        workers => 1
    }
    

    After this you'll be able to query episode with id 10

    GET http://localhost:9200/simpsons/episode/10
    
    0 讨论(0)
提交回复
热议问题