Elastix.Document (Elastix v0.10.0) View Source

The document APIs expose CRUD operations on documents.

Elastic documentation

Link to this section Summary

Link to this section Functions

Link to this function

delete(elastic_url, index_name, type_name, id, query_params \\ [])

View Source

Specs

delete(
  elastic_url :: String.t(),
  index :: String.t(),
  type :: String.t(),
  id :: String.t(),
  query_params :: Keyword.t()
) :: Elastix.HTTP.resp()

Deletes the documents matching the given id.

Examples

iex> Elastix.Document.delete("http://localhost:9200", "twitter", "tweet", "42")
{:ok, %HTTPoison.Response{...}}
Link to this function

delete_matching(elastic_url, index_name, query, query_params \\ [])

View Source

Specs

delete_matching(
  elastic_url :: String.t(),
  index :: String.t(),
  query :: map(),
  query_params :: Keyword.t()
) :: Elastix.HTTP.resp()

Deletes the documents matching the given query using the Delete By Query API.

Link to this function

get(elastic_url, index_name, type_name, id, query_params \\ [])

View Source

Specs

get(
  elastic_url :: String.t(),
  index :: String.t(),
  type :: String.t(),
  id :: String.t(),
  query_params :: Keyword.t()
) :: Elastix.HTTP.resp()

Fetches a document matching the given id.

Examples

iex> Elastix.Document.get("http://localhost:9200", "twitter", "tweet", "42")
{:ok, %HTTPoison.Response{...}}
Link to this function

index(elastic_url, index_name, type_name, id, data, query_params \\ [])

View Source

Specs

index(
  elastic_url :: String.t(),
  index :: String.t(),
  type :: String.t(),
  id :: String.t(),
  data :: map(),
  query_params :: Keyword.t()
) :: Elastix.HTTP.resp()

(Re)Indexes a document with the given id.

Examples

iex> Elastix.Document.index("http://localhost:9200", "twitter", "tweet", "42", %{user: "kimchy", post_date: "2009-11-15T14:12:12", message: "trying out Elastix"})
{:ok, %HTTPoison.Response{...}}
Link to this function

index_new(elastic_url, index_name, type_name, data, query_params \\ [])

View Source

Specs

index_new(
  elastic_url :: String.t(),
  index :: String.t(),
  type :: String.t(),
  data :: map(),
  query_params :: Keyword.t()
) :: Elastix.HTTP.resp()

Indexes a new document.

Examples

iex> Elastix.Document.index_new("http://localhost:9200", "twitter", "tweet", %{user: "kimchy", post_date: "2009-11-15T14:12:12", message: "trying out Elastix"})
{:ok, %HTTPoison.Response{...}}
Link to this function

mget(elastic_url, query, index_name \\ nil, type_name \\ nil, query_params \\ [])

View Source

Specs

mget(
  elastic_url :: String.t(),
  query :: map(),
  index :: String.t(),
  type :: String.t(),
  query_params :: Keyword.t()
) :: Elastix.HTTP.resp()

Fetches multiple documents matching the given query using the Multi Get API.

Link to this function

update(elastic_url, index_name, type_name, id, data, query_params \\ [])

View Source

Specs

update(
  elastic_url :: String.t(),
  index :: String.t(),
  type :: String.t(),
  id :: String.t(),
  data :: map(),
  query_params :: Keyword.t()
) :: Elastix.HTTP.resp()

Updates the document with the given id.

Examples

iex> Elastix.Document.update("http://localhost:9200", "twitter", "tweet", "42", %{user: "kimchy", message: "trying out Elastix.Document.update/5"})
{:ok, %HTTPoison.Response{...}}
Link to this function

update_by_query(elastic_url, index_name, query, script, query_params \\ [])

View Source

Specs

update_by_query(
  elastic_url :: String.t(),
  index :: String.t(),
  query :: map(),
  script :: map(),
  query_params :: Keyword.t()
) :: Elastix.HTTP.resp()

Updates the documents matching the given query using the Update By Query API.

Examples

iex> Elastix.Document.update_by_query("http://localhost:9200", "twitter", %{"term" => %{"user" => "kimchy"}}, %{inline: "ctx._source.user = 'kimchy updated'", lang: "painless"})
{:ok, %HTTPoison.Response{...}}