is there any way to import a json file(contains 100 documents) in elasticsearch server.?

前端 未结 9 1729
孤街浪徒
孤街浪徒 2020-12-04 10:39

Is there any way to import a JSON file (contains 100 documents) in elasticsearch server? I want to import a big json file into es-server..

9条回答
  •  鱼传尺愫
    2020-12-04 10:51

    Import no, but you can index the documents by using the ES API.

    You can use the index api to load each line (using some kind of code to read the file and make the curl calls) or the index bulk api to load them all. Assuming your data file can be formatted to work with it.

    Read more here : ES API

    A simple shell script would do the trick if you comfortable with shell something like this maybe (not tested):

    while read line
    do
    curl -XPOST 'http://localhost:9200///' -d "$line"
    done 

    Peronally, I would probably use Python either pyes or the elastic-search client.

    pyes on github
    elastic search python client

    Stream2es is also very useful for quickly loading data into es and may have a way to simply stream a file in. (I have not tested a file but have used it to load wikipedia doc for es perf testing)

提交回复
热议问题