View Source OffBroadway.Elasticsearch.Strategy behaviour (OffBroadwayElasticsearch v0.1.0)

Elasticseach supports many strategies for efficiently searching over large amounts of data, by adopting a strategy pattern, different strategies can be created and configured depending on the use case.

To learn more about other strategies see Elasticsearch docs: Paginating Search Results

Summary

Types

A keyword list of all Broadway options/state

A Elasticsearch document represented as a Map. To allow maximum control, the entire document is returned, including metadata along with the _source.

Callbacks

Optionally called after execute with the current broadway_state() and the results of execute, a list of document(). Depending on the search strategy used, Elasticsearch can return new state that needs to be used in the next request. For example, the ScrollSearch strategy must pass the current scroll_id to the next request to return the next batch of results.

Optionally called before the strategy is executed. It's often necessary to modify search parameters or other state of the producer before requests are sent to Elasticsearch.

Called immediately after before_execute with the modified broadway_state(). This function should make the request to Elasticsearch to satisfy demand.

Types

@type broadway_state() :: OffBroadway.Elasticsearch.broadway_state()

A keyword list of all Broadway options/state

@type document() :: OffBroadway.Elasticsearch.document()

A Elasticsearch document represented as a Map. To allow maximum control, the entire document is returned, including metadata along with the _source.

Callbacks

Link to this callback

after_execute(state, results)

View Source (optional)
@callback after_execute(
  state :: broadway_state(),
  results :: [document()]
) :: broadway_state()

Optionally called after execute with the current broadway_state() and the results of execute, a list of document(). Depending on the search strategy used, Elasticsearch can return new state that needs to be used in the next request. For example, the ScrollSearch strategy must pass the current scroll_id to the next request to return the next batch of results.

Link to this callback

before_execute(state, demand)

View Source (optional)
@callback before_execute(state :: broadway_state(), demand :: non_neg_integer()) ::
  broadway_state()

Optionally called before the strategy is executed. It's often necessary to modify search parameters or other state of the producer before requests are sent to Elasticsearch.

@callback execute(state :: broadway_state()) :: {broadway_state(), [document()]}

Called immediately after before_execute with the modified broadway_state(). This function should make the request to Elasticsearch to satisfy demand.