Elastex v0.2.0 Elastex.Index behaviour
Follows the Elasticsearch Indices API.
Summary
Functions
Adds a single alias for an index
Adds a single alias for an index
Defines a template that will automatically be applied when new indices are created
Checks for an alias for an index
Aliases an index with a name
Performs the analysis process on text and returns the token breakdown
Performs the analysis process on text and returns the token breakdown
Clears all or specific cache associated with all indicies
Clears all or specific cache associated with on or more indicies
Closes an index
Instantiates an index with default settings
Instantiates an index with settings
Deletes an index
Deletes an alias for an index
Deletes a template
Checks if index exists
Callback implementation for Elastex.Extender.extend_url/2
Flushes all indicies
Flushes one or more indicies
Merges all indicies
Merges one or more indicies
Retrieves information about one or more indices
Gets an alias for an index
Gets type mappings for a field(s)
Gets type mappings for an index
Gets type mappings for an index and type
Retrieves settings of index or indicies
Retrieves a template
Opens an index
Callback implementation for Elastex.Extender.params/2
Provides type mappings to an index
Provides type mappings to an index with type
Provides insight into on-going index shard recoveries cluster wide
Provides insight into on-going index shard recoveries for a specific index
Explicitly refreshes all indicies
Explicitly refreshes one or more indicies
Rollsover an index
Rollsover an index
Gets low level segment information that a Lucene index (shard-level) is built with for all indicies
Gets low level segment information that a Lucene index (shard-level) is built with for an index
Provides store information for shard copies of all indices
Provides store information for shard copies of a specific index
Shrinks an index
Shrinks an index with body
Provides statistics on different operations happening on all indicies
Provides statistics on different operations happening on an index
Initiates a synched flush manually on all indicies
Initiates a synched flush manually on one or more indicies
Checks the existence of a template
Checks if type exists
Changes all index level settings in real time
Changes specific index level settings in real time
Types
body :: map | nil
int_or_string :: non_neg_integer | String.t
Functions
Specs
Adds a single alias for an index.
Examples
iex> Elastex.Index.add_alias("twitter", "tw")
%Elastex.Builder {
url: "twitter/_alias/tw",
method: :put
}
Specs
Adds a single alias for an index.
Examples
iex> body = %{actions: [%{add: %{index: "test_2", alias: "test"}}]}
iex> Elastex.Index.add_alias(body, "twitter", "tw")
%Elastex.Builder {
url: "twitter/_alias/tw",
body: %{actions: [%{add: %{index: "test_2", alias: "test"}}]},
method: :put
}
Specs
Defines a template that will automatically be applied when new indices are created
Examples
iex> body = %{template: "te*", settings: %{number_of_shards: 1}}
iex> Elastex.Index.add_template(body, "template1")
%Elastex.Builder {
url: "_template/template1",
body: %{template: "te*", settings: %{number_of_shards: 1}},
method: :put
}
Specs
Checks for an alias for an index.
Examples
iex> Elastex.Index.alias_exists("twitter", "tw")
%Elastex.Builder {
url: "twitter/_alias/tw",
method: :head
}
Specs
Aliases an index with a name.
Examples
iex> body = %{actions: [%{add: %{index: "test_2", alias: "test"}}]}
iex> Elastex.Index.aliases(body)
%Elastex.Builder {
url: "_aliases",
body: %{actions: [%{add: %{index: "test_2", alias: "test"}}]},
method: :post
}
Specs
Performs the analysis process on text and returns the token breakdown.
Examples
iex> body = %{analyzer: 'standard', text: 'this is a test'}
iex> Elastex.Index.analyze(body)
%Elastex.Builder {
url: "_analyze",
body: %{analyzer: 'standard', text: 'this is a test'},
method: :get
}
Specs
Performs the analysis process on text and returns the token breakdown.
Examples
iex> body = %{analyzer: 'standard', text: 'this is a test'}
iex> Elastex.Index.analyze(body, "twitter")
%Elastex.Builder {
url: "twitter/_analyze",
body: %{analyzer: 'standard', text: 'this is a test'},
method: :get
}
Specs
clear_cache :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: :post, options: term, params: term, type: term, url: String.t}
Clears all or specific cache associated with all indicies.
Examples
iex> Elastex.Index.clear_cache()
%Elastex.Builder {
url: "_cache/clear",
method: :post
}
Specs
Clears all or specific cache associated with on or more indicies
Examples
iex> Elastex.Index.clear_cache("twitter")
%Elastex.Builder {
url: "twitter/_cache/clear",
method: :post
}
Specs
Closes an index
Examples
iex> Elastex.Index.close("twitter")
%Elastex.Builder {
url: "twitter/_close",
method: :post,
}
Specs
Instantiates an index with default settings.
Examples
iex> Elastex.Index.create("twitter")
%Elastex.Builder {
url: "twitter",
body: nil,
method: :put,
}
Specs
Instantiates an index with settings.
Examples
iex> settings = %{number_of_shards: 3}
iex> Elastex.Index.create(settings, "twitter")
%Elastex.Builder {
url: "twitter",
body: %{number_of_shards: 3},
method: :put,
}
Specs
Deletes an index.
Examples
iex> Elastex.Index.delete("twitter")
%Elastex.Builder {
url: "twitter",
method: :delete,
}
Specs
Deletes an alias for an index.
Examples
iex> Elastex.Index.delete_alias("twitter", "tw")
%Elastex.Builder {
url: "twitter/_alias/tw",
method: :delete
}
Specs
Deletes a template.
Examples
iex> Elastex.Index.delete_template("template1")
%Elastex.Builder {
url: "_template/template1",
method: :delete
}
Specs
Checks if index exists
Examples
iex> Elastex.Index.exists("twitter")
%Elastex.Builder {
url: "twitter",
method: :head,
}
Callback implementation for Elastex.Extender.extend_url/2
.
Specs
flush :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: :post, options: term, params: term, type: term, url: String.t}
Flushes all indicies
Examples
iex> Elastex.Index.flush()
%Elastex.Builder {
url: "_flush",
method: :post
}
Specs
Flushes one or more indicies
Examples
iex> Elastex.Index.flush("twitter")
%Elastex.Builder {
url: "twitter/_flush",
method: :post
}
Specs
force_merge :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: :post, options: term, params: term, type: term, url: String.t}
Merges all indicies
Examples
iex> Elastex.Index.force_merge()
%Elastex.Builder {
url: "_forcemerge",
method: :post
}
Specs
Merges one or more indicies
Examples
iex> Elastex.Index.force_merge("twitter")
%Elastex.Builder {
url: "twitter/_forcemerge",
method: :post
}
Specs
Retrieves information about one or more indices.
Examples
iex> Elastex.Index.get("twitter")
%Elastex.Builder {
url: "twitter",
method: :get,
}
Specs
Gets an alias for an index.
Examples
iex> Elastex.Index.get_alias("twitter", "tw")
%Elastex.Builder {
url: "twitter/_alias/tw",
method: :get
}
Specs
Gets type mappings for a field(s)
Examples
iex> Elastex.Index.get_field_mapping("twitter", "tweet", "message")
%Elastex.Builder {
url: "twitter/_mapping/tweet/field/message",
method: :get
}
Specs
Gets type mappings for an index
Examples
iex> Elastex.Index.get_mapping("twitter")
%Elastex.Builder {
url: "twitter/_mapping",
method: :get
}
Specs
Gets type mappings for an index and type
Examples
iex> Elastex.Index.get_mapping("twitter", "tweet")
%Elastex.Builder {
url: "twitter/_mapping/tweet",
method: :get
}
Specs
Retrieves settings of index or indicies
Examples
iex> Elastex.Index.get_settings("twitter")
%Elastex.Builder {
url: "twitter/_settings",
method: :get
}
Specs
Retrieves a template
Examples
iex> Elastex.Index.get_template("template1")
%Elastex.Builder {
url: "_template/template1",
method: :get
}
Specs
Opens an index
Examples
iex> Elastex.Index.open("twitter")
%Elastex.Builder {
url: "twitter/_open",
method: :post,
}
Callback implementation for Elastex.Extender.params/2
.
Specs
Provides type mappings to an index
Examples
iex> body = %{mappings: %{tweet: %{properties: %{message: %{type: "text"}}}}}
iex> Elastex.Index.put_mapping(body, "twitter")
%Elastex.Builder {
url: "twitter",
body: %{mappings: %{tweet: %{properties: %{message: %{type: "text"}}}}},
method: :put
}
Specs
Provides type mappings to an index with type
Examples
iex> body = %{mappings: %{tweet: %{properties: %{message: %{type: "text"}}}}}
iex> Elastex.Index.put_mapping(body, "twitter", "tweet")
%Elastex.Builder {
url: "twitter/_mapping/tweet",
body: %{mappings: %{tweet: %{properties: %{message: %{type: "text"}}}}},
method: :put
}
Specs
recovery :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: :get, options: term, params: term, type: term, url: String.t}
Provides insight into on-going index shard recoveries cluster wide.
Examples
iex> Elastex.Index.recovery()
%Elastex.Builder {
url: "_recovery",
method: :get
}
Specs
Provides insight into on-going index shard recoveries for a specific index.
Examples
iex> Elastex.Index.recovery()
%Elastex.Builder {
url: "_recovery",
method: :get
}
Specs
refresh :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: :post, options: term, params: term, type: term, url: String.t}
Explicitly refreshes all indicies
Examples
iex> Elastex.Index.refresh()
%Elastex.Builder {
url: "_refresh",
method: :post
}
Specs
Explicitly refreshes one or more indicies
Examples
iex> Elastex.Index.refresh("twitter")
%Elastex.Builder {
url: "twitter/_refresh",
method: :post
}
Specs
Rollsover an index
Examples
iex> body = %{conditions: %{max_age: "7d"}}
iex> Elastex.Index.rollover(body, "twitter")
%Elastex.Builder {
url: "twitter/_rollover",
body: %{conditions: %{max_age: "7d"}},
method: :post
}
Specs
Rollsover an index
Examples
iex> body = %{conditions: %{max_age: "7d"}}
iex> Elastex.Index.rollover(body, "twitter", "new_twitter")
%Elastex.Builder {
url: "twitter/_rollover/new_twitter",
body: %{conditions: %{max_age: "7d"}},
method: :post
}
Specs
segments :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: :get, options: term, params: term, type: term, url: String.t}
Gets low level segment information that a Lucene index (shard-level) is built with for all indicies.
Examples
iex> Elastex.Index.segments()
%Elastex.Builder {
url: "_segments",
method: :get
}
Specs
Gets low level segment information that a Lucene index (shard-level) is built with for an index.
Examples
iex> Elastex.Index.segments("twitter")
%Elastex.Builder {
url: "twitter/_segments",
method: :get
}
Specs
shard_stores :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: :get, options: term, params: term, type: term, url: String.t}
Provides store information for shard copies of all indices.
Examples
iex> Elastex.Index.shard_stores()
%Elastex.Builder {
url: "_shard_stores",
method: :get
}
Specs
Provides store information for shard copies of a specific index.
Examples
iex> Elastex.Index.shard_stores("twitter")
%Elastex.Builder {
url: "twitter/_shard_stores",
method: :get
}
Specs
Shrinks an index
Examples
iex> Elastex.Index.shrink("twitter", "new_twitter")
%Elastex.Builder {
url: "twitter/_shrink/new_twitter",
method: :post,
}
Specs
Shrinks an index with body
Examples
iex> body = %{settings: %{"index.number_of_replicas" => 1}}
iex> Elastex.Index.shrink(body, "twitter", "new_twitter")
%Elastex.Builder {
url: "twitter/_shrink/new_twitter",
body: %{settings: %{"index.number_of_replicas" => 1}},
method: :post
}
Specs
stats :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: :get, options: term, params: term, type: term, url: String.t}
Provides statistics on different operations happening on all indicies.
Examples
iex> Elastex.Index.stats()
%Elastex.Builder {
url: "_stats",
method: :get
}
Specs
Provides statistics on different operations happening on an index.
Examples
iex> Elastex.Index.stats("twitter")
%Elastex.Builder {
url: "twitter/_stats",
method: :get
}
Specs
synced_flush :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: :post, options: term, params: term, type: term, url: String.t}
Initiates a synched flush manually on all indicies
Examples
iex> Elastex.Index.synced_flush()
%Elastex.Builder {
url: "_flush/synced",
method: :post
}
Specs
Initiates a synched flush manually on one or more indicies
Examples
iex> Elastex.Index.synced_flush("twitter")
%Elastex.Builder {
url: "twitter/_flush/synced",
method: :post
}
Specs
Checks the existence of a template.
Examples
iex> Elastex.Index.template_exists("template1")
%Elastex.Builder {
url: "_template/template1",
method: :head
}
Specs
Checks if type exists
Examples
iex> Elastex.Index.type_exists("twitter", "tweet")
%Elastex.Builder {
url: "twitter/_mapping/tweet",
method: :head
}
Specs
Changes all index level settings in real time.
Examples
iex> body = %{index: %{number_of_replicas: 4}}
iex> Elastex.Index.update_settings(body)
%Elastex.Builder {
url: "_settings",
body: %{index: %{number_of_replicas: 4}},
method: :put
}
Specs
Changes specific index level settings in real time.
Examples
iex> body = %{index: %{number_of_replicas: 4}}
iex> Elastex.Index.update_settings(body, "twitter")
%Elastex.Builder {
url: "twitter/_settings",
body: %{index: %{number_of_replicas: 4}},
method: :put
}
Callbacks
Specs
extend_url(%Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: term, options: term, params: term, type: term, url: term}, [String.t]) :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: term, options: term, params: term, type: term, url: String.t}
Extends the url of cluster builder
Examples
iex> builder = %Elastex.Builder{url: "twitter"}
iex> Elastex.Index.extend_url(builder, ["tweet"])
%Elastex.Builder {
url: "twitter/tweet"
}
Specs
params(%Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: term, options: term, params: term, type: term, url: term}, keyword(String.t)) :: %Elastex.Builder{action: term, body: term, headers: term, id: term, index: term, method: term, options: term, params: keyword(String.t), type: term, url: term}
Adds params to document builders
Examples
iex> builder = %Elastex.Builder{}
iex> Elastex.Index.params(builder, [q: "user:mike"])
%Elastex.Builder {
params: [q: "user:mike"]
}