Version: v6.2.11+incompatible Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2018 License: MIT Imports: 11 Imported by: 0



BulkInsert illustrates how to bulk insert documents into Elasticsearch.

It uses two goroutines to do so. The first creates a simple document and sends it to the second via a channel. The second goroutine collects those documents, creates a bulk request that is added to a Bulk service and committed to Elasticsearch after reaching a number of documents. The number of documents after which a commit happens can be specified via the "bulk-size" flag.

See https://www.elastic.co/guide/en/elasticsearch/reference/6.2/docs-bulk.html for details on the Bulk API in Elasticsearch.


Bulk index 100.000 documents into the index "warehouse", type "product", committing every set of 1.000 documents.

bulk_insert -index=warehouse -type=product -n=100000 -bulk-size=1000

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL