exlasticsearch v1.10.1 ExlasticSearch.Model View Source
Base macro for generating elasticsearch modules. Is intended to be used in conjunction with a Ecto model (although that is not strictly necessary).
It includes three primary macros:
The usage is something like this
indexes :my_type do
settings Application.get_env(:some, :settings)
mapping :column
mapping :other_column, type: :keyword
end
This will set up settings and mappings for index my_types with type my_type (specify the singularized type in the macro, so pluralization works naturally).
The following functions will also be created:
__es_mappings__/0
- map of all fully specified mappings for the given type__mappings__/0
- columns with mappings for the given type__es_index__/0
- the elasticsearch index for this model__es_index__/1
- the elasticsearch index for reads/writes when performing zero-downtime updates (pass either:read
or:index
respectively)__doc_type__/0
- the default document type for searches in es_index()__es_settings__/0
- the settings for the index of this model
Link to this section Summary
Functions
Converts a search result to model
’s search result type
Opens up index definition for the current model. Will name the index and generate metadata
attributes for the index based on subsequent calls to settings/1
and mappings/2
Adds a new mapping to the ES schema. The type of the mapping will be inferred automatically, unless explictly set in props
A map of index settings. Structure is the same as specified by ES
Link to this section Functions
Converts a search result to model
’s search result type
Opens up index definition for the current model. Will name the index and generate metadata
attributes for the index based on subsequent calls to settings/1
and mappings/2
.
Accepts
type
- the indexes type (and index name will betype <> "s"
)block
- the definition of the index
Adds a new mapping to the ES schema. The type of the mapping will be inferred automatically, unless explictly set in props.
Accepts:
name
- the name of the mappingprops
- is a map/kw list of ES mapping configuration (e.g.search_analyzer: "my_search_analyzer", type: "text"
)
A map of index settings. Structure is the same as specified by ES.