elasticsearch v0.4.0 Elasticsearch.Document protocol View Source
A protocol for converting a struct into an Elasticsearch document.
Example
defimpl Elasticsearch.Document, for: MyStruct do
def id(struct), do: struct.id
def encode(struct) do
%{
id: struct.id,
name: struct.name
}
end
end
Link to this section Summary
Functions
Returns a map of fields, which will be converted to JSON and stored in Elasticsearch as a document
Returns the Elasticsearch _id
for the item
Link to this section Types
Link to this section Functions
Returns a map of fields, which will be converted to JSON and stored in Elasticsearch as a document.
Example
def encode(item) do
%{
title: item.title,
author: item.author
}
end