API Reference

High-level API to ElasticsearchClient. Each method receive ElasticsearchClient.Client and params as keyword arguments. Reponse similarto HTTP.Response, but it coverts body to String instead of CodeUnits or store body as Dict, if content type is application/json.

Example

using ElasticsearchClient

client = ElasticsearchClient.Client()

body = (
  query=(
    match_all=Dict(),
  ),
)

response = ElasticsearchClient.search(client, body=body)

@show response.body["took"]
ElasticsearchClient.API.ResponseType

Store Elastic response with body, headers and status

function Response(http_response::HTTP.Response)

Create response structure and convert body to String if it's CodeUnits

source
ElasticsearchClient.API.searchFunction

Returns results matching a query.

  • index::Union{String, Vector{String}}: A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • analyzer::String: The analyzer to use for the query string
  • analyze_wildcard::Bool: specify whether wildcard and prefix queries should be analyzed (default: false)
  • ccs_minimize_roundtrips::Bool: Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
  • default_operator::String: The default operator for query string query (AND or OR) (options: AND, OR)
  • df::String: The field to use as default where no field prefix is given in the query string
  • explain::Bool: Specify whether to return detailed information about score computation as part of a hit
  • stored_fields::{String, Vector{String}}: A comma-separated list of stored fields to return as part of a hit
  • docvalue_fields::{String, Vector{String}} A comma-separated list of fields to return as the docvalue representation of a field for each hit
  • from::Integer: Starting offset (default: 0)
  • force_synthetic_source::Bool: Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index.
  • ignore_unavailable::Bool: Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • ignore_throttled::Bool: Whether specified concrete, expanded or aliased indices should be ignored when throttled
  • allow_no_indices::Bool: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards::String: Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  • lenient::Bool: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • preference::String: Specify the node or shard the operation should be performed on (default: random)
  • q::String: Query in the Lucene query string syntax
  • routing::Union{String, Vector{String}}: A comma-separated list of specific routing values
  • scroll::DateTime: Specify how long a consistent view of the index should be maintained for scrolled search
  • search_type::String: Search operation type (options: querythenfetch, dfsquerythen_fetch)
  • size::Integer: Number of hits to return (default: 10)
  • sort::Union{String, Vector{String}}: A comma-separated list of <field>:<direction> pairs
  • _source::Union{String, Vector{String}}: True or false to return the _source field or not, or a list of fields to return
  • _source_excludes::Union{String, Vector{String}}: A list of fields to exclude from the returned _source field
  • _source_includes::Union{String, Vector{String}}: A list of fields to extract and return from the _source field
  • terminate_after::Integer: The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  • stats::Union{String, Vector{String}}: Specific 'tag' of the request for logging and statistical purposes
  • suggest_field::String: Specify which field to use for suggestions
  • suggest_mode::String: Specify suggest mode (options: missing, popular, always)
  • suggest_size::Integer: How many suggestions to return in response
  • suggest_text::String: The source text for which the suggestions should be returned
  • timeout::DateTime: Explicit operation timeout
  • track_scores::Bool: Whether to calculate and return scores even if they are not used for sorting
  • `[Boolean|long] :tracktotalhits Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.
  • allow_partial_search_results::Bool: Indicate if an error should be returned if there is a partial search failure or timeout
  • typed_keys::Bool: Specify whether aggregation and suggester names should be prefixed by their respective types in the response
  • version::Bool: Specify whether to return document version as part of a hit
  • seq_no_primary_term::Bool: Specify whether to return sequence number and primary term of the last modification of each hit
  • request_cache::Bool: Specify if request cache should be used for this request or not, defaults to index level setting
  • batched_reduce_size::Integer: The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.
  • max_concurrent_shard_requests::Integer: The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests
  • pre_filter_shard_size::Integer: A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
  • rest_total_hits_as_int::Bool: Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  • min_compatible_shard_node::String: The minimum compatible version that all shards involved in search should have for this request to be successful
  • headers::Dict: Custom HTTP headers
  • body::Union{Dict,NamedTuple}: The search definition using the Query DSL

See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html

source
ElasticsearchClient.API.search_templateFunction

Allows to use the Mustache language to pre-render a search definition.

  • index::Union{String,Vector{String}}: A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • ignore_unavailable::Bool: Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • ignore_throttled::Bool: Whether specified concrete, expanded or aliased indices should be ignored when throttled
  • allow_no_indices::Bool: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • expand_wildcards::String: Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  • preference::String: Specify the node or shard the operation should be performed on (default: random)
  • routing::Union{String,Vector{String}}: A comma-separated list of specific routing values
  • scroll::DateTime: Specify how long a consistent view of the index should be maintained for scrolled search
  • search_type::String: Search operation type (options: querythenfetch, dfsquerythen_fetch)
  • explain::Bool: Specify whether to return detailed information about score computation as part of a hit
  • profile::Bool: Specify whether to profile the query execution
  • typed_keys::Bool: Specify whether aggregation and suggester names should be prefixed by their respective types in the response
  • rest_total_hits_as_int::Bool: Indicates whether hits.total should be rendered as an integer or an object in the rest search response
  • ccs_minimize_roundtrips::Bool: Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
  • headers::Dict: Custom HTTP headers
  • body::Union{Dict,NamedTuple}: The search definition template and its params (Required)

See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html

source
ElasticsearchClient.API.put_scriptFunction

Creates or updates a script.

  • id::String: Script ID
  • context::String: Script context
  • timeout::DateTime: Explicit operation timeout
  • master_timeout::DateTime: Specify timeout for connection to master
  • headers::Dict: Custom HTTP headers
  • body::Union{Dict,NamedTuple}: The document (Required)

See https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html

source
ElasticsearchClient.API.indexFunction

Creates or updates a document in an index.

  • id::String: Document ID
  • index::String: The name of the index
  • wait_for_active_shards::String: Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
  • op_type::String: Explicit operation type. Defaults to index for requests with an explicit document ID, and to createfor requests without an explicit document ID (options: index, create)
  • refresh::String: If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes. (options: true, false, wait_for)
  • routing::String: Specific routing value
  • timeout::DateTime: Explicit operation timeout
  • version::Integer: Explicit version number for concurrency control
  • version_type::String: Specific version type (options: internal, external, external_gte)
  • if_seq_no::Integer: only perform the index operation if the last operation that has changed the document has the specified sequence number
  • if_primary_term::Integer: only perform the index operation if the last operation that has changed the document has the specified primary term
  • pipeline::String: The pipeline id to preprocess incoming documents with
  • require_alias::Bool: When true, requires destination to be an alias. Default is false
  • headers::Dict: Custom HTTP headers
  • body::Union{NamedTuple,Dict}: The document (Required)

See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html

source
ElasticsearchClient.API.bulkFunction

Allows to perform multiple index/update/delete operations in a single request.

  • index::String: Default index for items which don't provide one
  • wait_for_active_shards::String: Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
  • refresh::String: If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes. (options: true, false, wait_for)
  • routing::String: Specific routing value
  • timeout::DateTime: Explicit operation timeout
  • type::String: Default document type for items which don't provide one
  • _source::Union{Vector{String}, String}: True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request
  • _source_excludes::Union{Vector{String}, String}: Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
  • _source_includes::Union{Vector{String}, String}: Default list of fields to extract and return from the _source field, can be overridden on each sub-request
  • pipeline::String: The pipeline id to preprocess incoming documents with
  • require_alias::Bool: Sets require_alias for all incoming documents. Defaults to unset (false)
  • headers::Bool: Custom HTTP headers
  • body::Union{String,Vector}: The operation definition and data (action-data pairs), separated by newlines. Array of String or Dicts or NamedTuples

See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html

source
ElasticsearchClient.API.deleteFunction

Removes a document from the index.

  • id::String: The document ID
  • index::String: The name of the index
  • wait_for_active_shards::String: Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
  • refresh::String: If true then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes. (options: true, false, wait_for)
  • routing::String: Specific routing value
  • timeout::DateTime: Explicit operation timeout
  • if_seq_no::Integer: only perform the delete operation if the last operation that has changed the document has the specified sequence number
  • if_primary_term::Integer: only perform the delete operation if the last operation that has changed the document has the specified primary term
  • version::Integer: Explicit version number for concurrency control
  • version_type::String: Specific version type (options: internal, external, external_gte)
  • headers::Dict: Custom HTTP headers

See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html

source
ElasticsearchClient.API.delete_by_queryFunction

Deletes documents matching the provided query.

  • index::Union{String, Vector{String}}: A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices
  • analyzer::String: The analyzer to use for the query string
  • analyze_wildcard::Bool: Specify whether wildcard and prefix queries should be analyzed (default: false)
  • default_operator::String: The default operator for query string query (AND or OR) (options: AND, OR)
  • df::String: The field to use as default where no field prefix is given in the query string
  • from::Integer: Starting offset (default: 0)
  • ignore_unavailable::Bool: Whether specified concrete indices should be ignored when unavailable (missing or closed)
  • allow_no_indices::Bool: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified)
  • conflicts::String: What to do when the delete by query hits version conflicts? (options: abort, proceed)
  • expand_wildcards::String: Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  • lenient::Bool: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  • preference::String: Specify the node or shard the operation should be performed on (default: random)
  • q::String: Query in the Lucene query string syntax
  • routing::Union{String, Vector{String}}: A comma-separated list of specific routing values
  • scroll::DateTime: Specify how long a consistent view of the index should be maintained for scrolled search
  • search_type::String: Search operation type (options: querythenfetch, dfsquerythen_fetch)
  • search_timeout::DateTime: Explicit timeout for each search request. Defaults to no timeout.
  • max_docs::Integer: Maximum number of documents to process (default: all documents)
  • sort::Union{String, Vector{String}}: A comma-separated list of <field>:<direction> pairs
  • terminate_after::Integer: The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
  • stats::Union{String, Vector{String}}: Specific 'tag' of the request for logging and statistical purposes
  • version::Bool: Specify whether to return document version as part of a hit
  • request_cache::Bool: Specify if request cache should be used for this request or not, defaults to index level setting
  • refresh::Bool: Should the affected indexes be refreshed?
  • timeout::DateTime: Time each individual bulk request should wait for shards that are unavailable.
  • wait_for_active_shards::String: Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
  • scroll_size::Integer: Size on the scroll request powering the delete by query
  • wait_for_completion::Bool: Should the request should block until the delete by query is complete.
  • requests_per_second::Integer: The throttle for this request in sub-requests per second. -1 means no throttle.
  • slices::Union{Dict,String}: The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to auto.
  • headers::Dict: Custom HTTP headers
  • body::Dict: The search definition using the Query DSL (Required)

See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html

source