elasticsearch v0.3.1 Elasticsearch.Index.Bulk View Source
Functions for creating bulk indexing requests.
Link to this section Summary
Functions
Encodes a given variable into an Elasticsearch bulk request. The variable
must implement Elasticsearch.Document
Same as encode/3
, but returns the request and raises errors
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
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,"author":null}
"""}
iex> Bulk.encode(Cluster, 123, "my-index")
{:error,
%Protocol.UndefinedError{description: "",
protocol: Elasticsearch.Document, value: 123}}
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,"author":null}
"""
iex> Bulk.encode!(Cluster, 123, "my-index")
** (Protocol.UndefinedError) protocol Elasticsearch.Document not implemented for 123. This protocol is implemented for: Post
Uploads all the data from the list of sources
to the given index.
Data for each source
will be fetched using the configured :store
.