elasticsearch v1.0.0 Elasticsearch.Index.Bulk View Source
Functions for creating bulk indexing requests.
Link to this section Summary
Functions
Same as encode/3
, but returns the request and raises errors
Encodes a given variable into an Elasticsearch bulk request. The variable
must implement Elasticsearch.Document
Uploads all the data from the list of sources
to the given index.
Data for each source
will be fetched using the configured :store
Link to this section Functions
Same as encode/3
, but returns the request and raises errors.
Example
iex> Bulk.encode!(Cluster, %Post{id: "my-id"}, "my-index")
"""
{"create":{"_index":"my-index","_id":"my-id"}}
{"title":null,"doctype":{"name":"post"},"author":null}
"""
iex> Bulk.encode!(Cluster, 123, "my-index")
** (Protocol.UndefinedError) protocol Elasticsearch.Document not implemented for 123. This protocol is implemented for: Comment, Post
Link to this function
encode(cluster, struct, index)
View Source
encode(Elasticsearch.Cluster.t(), struct(), String.t()) :: {:ok, String.t()} | {:error, Error.t()}
Encodes a given variable into an Elasticsearch bulk request. The variable
must implement Elasticsearch.Document
.
Examples
iex> Bulk.encode(Cluster, %Post{id: "my-id"}, "my-index")
{:ok, """
{"create":{"_index":"my-index","_id":"my-id"}}
{"title":null,"doctype":{"name":"post"},"author":null}
"""}
iex> Bulk.encode(Cluster, 123, "my-index")
{:error,
%Protocol.UndefinedError{description: "",
protocol: Elasticsearch.Document, value: 123}}
Link to this function
upload(cluster, index_name, index_config, errors \\ [])
View Source
upload( Elasticsearch.Cluster.t(), index_name :: String.t(), Elasticsearch.Store.t(), list() ) :: :ok | {:error, [map()]}
Uploads all the data from the list of sources
to the given index.
Data for each source
will be fetched using the configured :store
.