Documentation ¶
Overview ¶
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.
Example ¶
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
Click to show internal directories.
Click to hide internal directories.