View Source ExlasticSearch.Repo (exlasticsearch v2.2.3)

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"

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 all document based on the query using the provided script.

Updates the index for model

Types

response()

@type response() ::
  {:ok,
   %HTTPoison.Response{
     body: term(),
     headers: term(),
     request: term(),
     request_url: term(),
     status_code: term()
   }}
  | {:error, any()}

Functions

aggregate(query, aggregation)

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

bulk(operations, index \\ :index, query_params \\ [], opts \\ [])

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}
]

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

close_index(model, index \\ :index)

Close an index for model

create_alias(model, list, index \\ :index)

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

create_index(model, index \\ :index)

Creates an index as defined in model

create_mapping(model, index \\ :index, opts \\ [])

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

delete(struct, index \\ :index)

Removes struct from the index of its model

delete_index(model, index \\ :index)

Removes the index defined in model

exists?(model, index \\ :read)

Checks if the index for model exists

get(struct, index_type \\ :read)

Gets an ES document by _id

get_alias(model, index)

@spec get_alias(atom(), atom()) :: response()

Retries the aliases for a given index

index(struct, index \\ :index)

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

index_stream(stream, index \\ :index, parallelism \\ 10, demand \\ 10)

open_index(model, index \\ :index)

open an index for model

paginate(pageable, options \\ [])

@spec paginate(any(), map() | Keyword.t()) :: Scrivener.Page.t()

refresh(model, index \\ :read)

Refreshes model's index

rotate(model, read \\ :read, index \\ :index)

@spec rotate(atom(), atom(), atom()) :: response()

Deletes the read index and aliases the write index to it

scrivener_defaults()

@spec scrivener_defaults() :: Keyword.t()

search(query, params)

@spec search(ExlasticSearch.Query.t(), list()) ::
  {:ok, %ExlasticSearch.Response.Search{hits: term(), total: term()}}
  | {:error, any()}

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

search(model, search, params, index_type \\ :read)

@spec search(atom(), map(), list(), any()) ::
  {:ok, %ExlasticSearch.Response.Search{hits: term(), total: term()}}
  | {:error, any()}

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

update(model, id, data, index \\ :index)

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

update_by_query(model, query, script, index \\ :index)

Updates all document based on the query using the provided script.

update_index(model, index \\ :index)

Updates the index for model