exlasticsearch v1.10.1 ExlasticSearch.Repo View Source

API executor for elasticsearch. The generate pattern is to define a ExlasticSearch.Model on an ecto model, then call any of these functions to manage the model.

To configure the url the repo points to, do:

config :exlasticsearch, ExlasticSearch.Repo,
  url: "https://elasticsearch.url.io:9200"

Link to this section Summary

Functions

Performs an aggregation against a query, and returns only the aggregation results

Generates an Elasticsearch bulk request. operations should be of the form

Close an index for model

Aliases one index version to another, for instance

Creates an index as defined in model

Updates an index’s mappings to the current definition in model

Removes struct from the index of its model

Removes the index defined in model

Checks if the index for model exists

Gets an ES document by _id

Retries the aliases for a given index

Adds a struct into it’s associated index. The struct will be passed through the ExlasticSearch.Indexable protocol prior to insertion

open an index for model

Refreshes model’s index

Deletes the read index and aliases the write index to it

Creates a call to search/3 by realizing query (using Exlasticsearch.Query.realize/1) and any provided search opts

Searches the index and type associated with model according to query search

Updates the document of the passed in id for the index associated to the model

Updates the index for model

Updates a nested field of the document of the passed in id for the index associated to the model

Link to this section Types

Link to this type response() View Source
response() ::
  {:ok,
   %HTTPoison.Response{
     body: term(),
     headers: term(),
     request_url: term(),
     status_code: term()
   }}
  | {:error, any()}

Link to this section Functions

Link to this function aggregate(query, aggregation) View Source

Performs an aggregation against a query, and returns only the aggregation results.

Link to this function bulk(operations, index \\ :index, opts \\ []) View Source

Generates an Elasticsearch bulk request. operations should be of the form:

Note: the last element in each Tuple is optional and will default to :index

[
  {:index, struct, index},
  {:delete, other_struct, index},
  {:update, third_struct, id, map, index},
  {:nested, id, source, map, index}
]

The function will handle formatting the bulk request properly and passing each struct to the ExlasticSearch.Indexable protocol

Link to this function close_index(model, index \\ :index) View Source

Close an index for model

Link to this function create_alias(model, list, index \\ :index) View Source

Aliases one index version to another, for instance:

alias(MyModel, read: :index)

will create an alias of the read version of the model’s index against it’s indexing version

Link to this function create_index(model, index \\ :index) View Source

Creates an index as defined in model

Link to this function create_mapping(model, index \\ :index) View Source

Updates an index’s mappings to the current definition in model

Link to this function delete(struct, index \\ :index) View Source

Removes struct from the index of its model

Link to this function delete_index(model, index \\ :index) View Source

Removes the index defined in model

Link to this function exists?(model, index \\ :read) View Source

Checks if the index for model exists

Link to this function get(struct, index_type \\ :read) View Source

Gets an ES document by _id

Link to this function get_alias(model, index) View Source
get_alias(atom(), atom()) :: response()

Retries the aliases for a given index

Link to this function index(struct, index \\ :index) View Source

Adds a struct into it’s associated index. The struct will be passed through the ExlasticSearch.Indexable protocol prior to insertion

Link to this function index_stream(stream, index \\ :index, parallelism \\ 10, demand \\ 10) View Source
Link to this function open_index(model, index \\ :index) View Source

open an index for model

Link to this function paginate(pageable, options \\ []) View Source
paginate(any(), map() | Keyword.t()) :: Scrivener.Page.t()
Link to this function refresh(model, index \\ :read) View Source

Refreshes model’s index

Link to this function rotate(model, read \\ :read, index \\ :index) View Source
rotate(atom(), atom(), atom()) :: response()

Deletes the read index and aliases the write index to it

Creates a call to search/3 by realizing query (using Exlasticsearch.Query.realize/1) and any provided search opts

Link to this function search(model, search, params, index_type \\ :read) View Source

Searches the index and type associated with model according to query search

Link to this function update(model, id, updates, index \\ :index) View Source

Updates the document of the passed in id for the index associated to the model

Link to this function update_index(model, index \\ :index) View Source

Updates the index for model

Link to this function update_nested(model, id, source, updates, index \\ :index) View Source

Updates a nested field of the document of the passed in id for the index associated to the model.

the source param is the script you want to apply for the update.