Member-only story

Elasticsearch

Populate data to Elasticsearch in Go

For populating data, we will use bulk API of Elasticsearch.

Donald Le

--

Photo by Austin Hervias on Unsplash

We will use github.com/elastic/go-elasticsearch/v6 as Elasticsearch client.

The input data we can store in csv, json, or any text format. All we have to do is creating the elasticsearch client, and read data from the text format.

Notes: We have to provide enough information about meta data of each request for populating : index_id, index_name, data_name

meta := []byte(fmt.Sprintf(`{ "index" : { "_index": "%s", "_type": "%s","_id" : "%d" } }%s`, indexName, "variants_gene_panel", i, "\n"))

Running the file will show the progress of data index and success response

Sucessfuly indexed [577,066] documents in 1m4.169s (8,992 docs/sec)

~~Hope it helps~~

~~PEACE~~

--

--

No responses yet