ESx v0.7.1 ESx.Model
Simply use ESx.Model.Base
Summary
Functions
Create index with any options
Search document from the data store matching the given query
Functions
Create index with any options.
Options
:index
- document index name:type
- document type name
Example
# Make index with defined schema
MyESx.create_index MyModel
# Make index with defined schema
MyESx.create_index MyModel, index: "any-index", type: "any-type"
Search document from the data store matching the given query.
Options
:index
- document index name in es:type
- document type name in es
Example
# Search 'my document' from elasticsearch
query = MyESx.search MyModel, %{query: %{match: %{title: "my document"}}}
# Featch docuemnt from elasticsarch
MyESx.results query
# Featch docuemnt from elasticsarch as Record struct which contains [Ecto.Schema.t] records.
MyESx.records query
Example with ecto queryable
# Set condition as issues ecto query.
query = from q in MyModel,
where: q.publish == true,
preload: [:thumbs, :category, :maker]
# Search 'my document' from elasticsearch
query = MyESx.search query, %{query: %{match: %{title: "my document"}}}
# Featch docuemnt from elasticsarch
MyESx.results query
# Featch docuemnt from elasticsarch as Record struct which contains [Ecto.Schema.t] records.
MyESx.records query