exlasticsearch v1.2.2 ExlasticSearch.Response View Source
Base module for ES response parsing. Works off a few macros, schema/1
, field/1
, has_many/2
, has_one/2
The usage is more or less:
use ExlasticSearch.Response
schema do
field :total
has_many :hits, HitsModule
end
This will define:
- a struct for carrying the response
parse/2
- converts a json decoded map from ES to the given response struct, and converting any models appropriatelyto_model/2
- performs model conversion if possible (defaults to no-op)
Link to this section Summary
Functions
Safe conversion of string keyed ES response maps to structifiable atom keyed maps
Adds a simple field attribute
Adds a has_many relation or the parser, which assumes a list value
Adds a has_one relation or the parser
Utility for recursively parsing response associations
Opens up the schema definition macro. Once closed, the following will be defined
Link to this section Functions
Safe conversion of string keyed ES response maps to structifiable atom keyed maps
Adds a simple field attribute
Adds a has_many relation or the parser, which assumes a list value
Accepts:
- field - the name of the relation
- parser - module of the responsible parser for parsing it
Adds a has_one relation or the parser
Accepts:
- field - the name of the relation
- parser - module of the responsible parser for parsing it
Utility for recursively parsing response associations
Opens up the schema definition macro. Once closed, the following will be defined:
__schema__(:parse_spec)
- A table for converting string keyed maps to atom keyed__schema__(:attributes)
- basic field attributes__schema__(:associations)
- a table of associations for the response, along with the responsible parser