Elasticsearch.Store behaviour (elasticsearch v1.1.0) View Source

A behaviour for fetching data to index using a streaming strategy.

Link to this section Summary

Callbacks

Returns a stream of the given datasource.

Returns a transaction wrapper to execute the stream returned by stream/1 within. This is required when using Ecto.

Link to this section Callbacks

Specs

stream(any()) :: Stream.t()

Returns a stream of the given datasource.

Example

def stream(Post) do
  Repo.stream(Post)
end

Specs

transaction((... -> any())) :: any()

Returns a transaction wrapper to execute the stream returned by stream/1 within. This is required when using Ecto.

Example

def transaction(fun) do
  {:ok, result} = Repo.transaction(fun, timeout: :infinity)
  result
end

If you are not using Ecto and do not require transactions, simply call the function passed as a parameter.

def transaction(fun) do
  fun.()
end