mix elasticsearch.build (elasticsearch v1.1.0) View Source

Builds Elasticsearch indexes using a zero-downtime, hot-swap technique.

  1. Build an index for the given alias, with a timestamp: alias-12323123
  2. Bulk upload data to that index using store and sources.
  3. Alias the alias to alias-12323123.
  4. Remove old indexes beginning with alias.
  5. Refresh alias-12323123.

For a functional version of this approach, see Elasticsearch.Index.hot_swap/4.


--cluster: The Elasticsearch.Cluster to build the indexes to.

--bulk-page-size: (Optional) The number of documents to post to the cluster in each bulk page upload. Default: 5000

--bulk-wait-interval: (Optional) The number of milliseconds to wait between posting each bulk page, to avoid overloading your cluster. Default: 0


$ mix elasticsearch.build posts [index2] [index3] --cluster MyApp.Cluster

To build an index only if it does not exist, use the --existing option:

$ mix elasticsearch.build posts --existing --cluster MyApp.Cluster
Index posts already exists.

You can also specify --bulk-page-size and --bulk-wait-interval manually:

$ mix elasticsearch.build posts --cluster MyApp.Cluster --bulk-page-size 1000 --bulk-wait-interval 500