elasticsearch v0.1.0 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/1
, 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
Encodes a given variable into an Elasticsearch bulk request. The variable
must implement Elasticsearch.Document
.
Examples
iex> Bulk.encode(%Post{id: "my-id"}, "my-index")
{:ok, """
{"create":{"_type":"post","_index":"my-index","_id":"my-id"}}
{"title":null,"author":null}
"""}
iex> Bulk.encode(123, "my-index")
{:error,
%Protocol.UndefinedError{description: "",
protocol: Elasticsearch.Document, value: 123}}
Same as encode/1
, but returns the request and raises errors.
Example
iex> Bulk.encode!(%Post{id: "my-id"}, "my-index")
"""
{"create":{"_type":"post","_index":"my-index","_id":"my-id"}}
{"title":null,"author":null}
"""
iex> Bulk.encode!(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
.