pub struct OsClient { /* private fields */ }
Expand description
Client for OpenSearch
Version: 2021-11-23
Implementations§
Source§impl OsClient
impl OsClient
Sourcepub fn new(baseurl: Url) -> Self
pub fn new(baseurl: Url) -> Self
Create a new client.
baseurl
is the base URL provided to the internal
reqwest::Client
, and should include a scheme and hostname,
as well as port and a path stem if applicable.
pub fn from_environment() -> Result<OsClient, Error>
Sourcepub fn client(&self) -> &ClientWithMiddleware
pub fn client(&self) -> &ClientWithMiddleware
Get the internal reqwest_middleware::ClientWithMiddleware
used to make
requests.
Sourcepub fn api_version(&self) -> &'static str
pub fn api_version(&self) -> &'static str
Get the version of this API.
This string is pulled directly from the source OpenAPI document and may be in any format the API selects.
pub async fn send<T: Request + Serialize>( &self, request: T, ) -> Result<ResponseValue<T::Response>, Error>
Source§impl OsClient
impl OsClient
Sourcepub fn info(&self) -> Info<'_>
pub fn info(&self) -> Info<'_>
Returns basic information about the cluster.
Sends a GET
request to /
let response = client.info()
.send()
.await;
Sourcepub fn ping(&self) -> Ping<'_>
pub fn ping(&self) -> Ping<'_>
Returns whether the cluster is running.
Sends a HEAD
request to /
let response = client.ping()
.send()
.await;
Sourcepub fn bulk(&self) -> BulkPost<'_>
pub fn bulk(&self) -> BulkPost<'_>
Allows to perform multiple index/update/delete operations in a single request.
Sends a POST
request to /_bulk
Arguments:
source
: 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
: Default list of fields to exclude from the returned _source field, can be overridden on each sub-request.source_includes
: Default list of fields to extract and return from the _source field, can be overridden on each sub-request.pipeline
: The pipeline id to preprocess incoming documents with.refresh
: Iftrue
then refresh the affected shards to make this operation visible to search, ifwait_for
then wait for a refresh to make this operation visible to search, iffalse
(the default) then do nothing with refreshes.require_alias
: Sets require_alias for all incoming documents.routing
: Routing value.timeout
: Operation timeout.type_
: Default document type for items which don’t provide one.wait_for_active_shards
: Sets the number of shard copies that must be active before proceeding with the operation. Defaults to 1, meaning the primary shard only. Set toall
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).body
let response = client.bulk_post()
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.pipeline(pipeline)
.refresh(refresh)
.require_alias(require_alias)
.routing(routing)
.timeout(timeout)
.type_(type_)
.wait_for_active_shards(wait_for_active_shards)
.body(body)
.send()
.await;
Sourcepub fn dangling_indices_list_dangling_indices(
&self,
) -> DanglingIndicesListDanglingIndices<'_>
pub fn dangling_indices_list_dangling_indices( &self, ) -> DanglingIndicesListDanglingIndices<'_>
Returns all dangling indices.
Sends a GET
request to /_dangling
let response = client.dangling_indices_list_dangling_indices()
.send()
.await;
Sourcepub fn dangling_indices_import_dangling_index(
&self,
) -> DanglingIndicesImportDanglingIndex<'_>
pub fn dangling_indices_import_dangling_index( &self, ) -> DanglingIndicesImportDanglingIndex<'_>
Imports the specified dangling index.
Sends a POST
request to /_dangling/{index_uuid}
Arguments:
index_uuid
: The UUID of the dangling index.accept_data_loss
: Must be set to true in order to import the dangling index.cluster_manager_timeout
: Operation timeout for connection to cluster-manager node.master_timeout
: Operation timeout for connection to master node.timeout
: Operation timeout.
let response = client.dangling_indices_import_dangling_index()
.index_uuid(index_uuid)
.accept_data_loss(accept_data_loss)
.cluster_manager_timeout(cluster_manager_timeout)
.master_timeout(master_timeout)
.timeout(timeout)
.send()
.await;
Sourcepub fn dangling_indices_delete_dangling_index(
&self,
) -> DanglingIndicesDeleteDanglingIndex<'_>
pub fn dangling_indices_delete_dangling_index( &self, ) -> DanglingIndicesDeleteDanglingIndex<'_>
Deletes the specified dangling index.
Sends a DELETE
request to /_dangling/{index_uuid}
Arguments:
index_uuid
: The UUID of the dangling index.accept_data_loss
: Must be set to true in order to delete the dangling index.cluster_manager_timeout
: Operation timeout for connection to cluster-manager node.master_timeout
: Operation timeout for connection to master node.timeout
: Operation timeout.
let response = client.dangling_indices_delete_dangling_index()
.index_uuid(index_uuid)
.accept_data_loss(accept_data_loss)
.cluster_manager_timeout(cluster_manager_timeout)
.master_timeout(master_timeout)
.timeout(timeout)
.send()
.await;
Sourcepub fn delete_by_query_rethrottle(&self) -> DeleteByQueryRethrottle<'_>
pub fn delete_by_query_rethrottle(&self) -> DeleteByQueryRethrottle<'_>
Changes the number of requests per second for a particular Delete By Query operation.
Sends a POST
request to /_delete_by_query/{task_id}/_rethrottle
Arguments:
task_id
: The task id to rethrottle.requests_per_second
: The throttle for this request in sub-requests per second. -1 means no throttle.
let response = client.delete_by_query_rethrottle()
.task_id(task_id)
.requests_per_second(requests_per_second)
.send()
.await;
Sourcepub fn field_caps_get(&self) -> FieldCapsGet<'_>
pub fn field_caps_get(&self) -> FieldCapsGet<'_>
Returns the information about the capabilities of fields among multiple indices.
Sends a GET
request to /_field_caps
Arguments:
allow_no_indices
: 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
: Whether to expand wildcard expression to concrete indices that are open, closed or both.fields
: Comma-separated list of field names.ignore_unavailable
: Whether specified concrete indices should be ignored when unavailable (missing or closed).include_unmapped
: Indicates whether unmapped fields should be included in the response.
let response = client.field_caps_get()
.allow_no_indices(allow_no_indices)
.expand_wildcards(expand_wildcards)
.fields(fields)
.ignore_unavailable(ignore_unavailable)
.include_unmapped(include_unmapped)
.send()
.await;
Sourcepub fn field_caps_post(&self) -> FieldCapsPost<'_>
pub fn field_caps_post(&self) -> FieldCapsPost<'_>
Returns the information about the capabilities of fields among multiple indices.
Sends a POST
request to /_field_caps
Arguments:
allow_no_indices
: 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
: Whether to expand wildcard expression to concrete indices that are open, closed or both.fields
: Comma-separated list of field names.ignore_unavailable
: Whether specified concrete indices should be ignored when unavailable (missing or closed).include_unmapped
: Indicates whether unmapped fields should be included in the response.body
let response = client.field_caps_post()
.allow_no_indices(allow_no_indices)
.expand_wildcards(expand_wildcards)
.fields(fields)
.ignore_unavailable(ignore_unavailable)
.include_unmapped(include_unmapped)
.body(body)
.send()
.await;
Sourcepub fn mget_get(&self) -> MgetGet<'_>
pub fn mget_get(&self) -> MgetGet<'_>
Allows to get multiple documents in one request.
Sends a GET
request to /_mget
Arguments:
source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.preference
: Specify the node or shard the operation should be performed on.realtime
: Specify whether to perform the operation in realtime or search mode.refresh
: Refresh the shard containing the document before performing the operation.routing
: Routing value.stored_fields
: Comma-separated list of stored fields to return.
let response = client.mget_get()
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.preference(preference)
.realtime(realtime)
.refresh(refresh)
.routing(routing)
.stored_fields(stored_fields)
.send()
.await;
Sourcepub fn mget_post(&self) -> MgetPost<'_>
pub fn mget_post(&self) -> MgetPost<'_>
Allows to get multiple documents in one request.
Sends a POST
request to /_mget
Arguments:
source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.preference
: Specify the node or shard the operation should be performed on.realtime
: Specify whether to perform the operation in realtime or search mode.refresh
: Refresh the shard containing the document before performing the operation.routing
: Routing value.stored_fields
: Comma-separated list of stored fields to return.body
let response = client.mget_post()
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.preference(preference)
.realtime(realtime)
.refresh(refresh)
.routing(routing)
.stored_fields(stored_fields)
.body(body)
.send()
.await;
Sourcepub fn msearch_get(&self) -> MsearchGet<'_>
pub fn msearch_get(&self) -> MsearchGet<'_>
Allows to execute several search operations in one request.
Sends a GET
request to /_msearch
Arguments:
ccs_minimize_roundtrips
: Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.max_concurrent_searches
: Controls the maximum number of concurrent searches the multi search api will execute.max_concurrent_shard_requests
: The number of concurrent shard requests each sub search executes concurrently per node. 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
: Threshold that enforces a pre-filter round-trip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter round-trip 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
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.search_type
: Search operation type.typed_keys
: Specify whether aggregation and suggester names should be prefixed by their respective types in the response.
let response = client.msearch_get()
.ccs_minimize_roundtrips(ccs_minimize_roundtrips)
.max_concurrent_searches(max_concurrent_searches)
.max_concurrent_shard_requests(max_concurrent_shard_requests)
.pre_filter_shard_size(pre_filter_shard_size)
.rest_total_hits_as_int(rest_total_hits_as_int)
.search_type(search_type)
.typed_keys(typed_keys)
.send()
.await;
Sourcepub fn msearch_post(&self) -> MsearchPost<'_>
pub fn msearch_post(&self) -> MsearchPost<'_>
Allows to execute several search operations in one request.
Sends a POST
request to /_msearch
Arguments:
ccs_minimize_roundtrips
: Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.max_concurrent_searches
: Controls the maximum number of concurrent searches the multi search api will execute.max_concurrent_shard_requests
: The number of concurrent shard requests each sub search executes concurrently per node. 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
: Threshold that enforces a pre-filter round-trip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter round-trip 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
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.search_type
: Search operation type.typed_keys
: Specify whether aggregation and suggester names should be prefixed by their respective types in the response.body
let response = client.msearch_post()
.ccs_minimize_roundtrips(ccs_minimize_roundtrips)
.max_concurrent_searches(max_concurrent_searches)
.max_concurrent_shard_requests(max_concurrent_shard_requests)
.pre_filter_shard_size(pre_filter_shard_size)
.rest_total_hits_as_int(rest_total_hits_as_int)
.search_type(search_type)
.typed_keys(typed_keys)
.body(body)
.send()
.await;
Sourcepub fn msearch_template_get(&self) -> MsearchTemplateGet<'_>
pub fn msearch_template_get(&self) -> MsearchTemplateGet<'_>
Allows to execute several search template operations in one request.
Sends a GET
request to /_msearch/template
Arguments:
ccs_minimize_roundtrips
: Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.max_concurrent_searches
: Controls the maximum number of concurrent searches the multi search api will execute.rest_total_hits_as_int
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.search_type
: Search operation type.typed_keys
: Specify whether aggregation and suggester names should be prefixed by their respective types in the response.
let response = client.msearch_template_get()
.ccs_minimize_roundtrips(ccs_minimize_roundtrips)
.max_concurrent_searches(max_concurrent_searches)
.rest_total_hits_as_int(rest_total_hits_as_int)
.search_type(search_type)
.typed_keys(typed_keys)
.send()
.await;
Sourcepub fn msearch_template_post(&self) -> MsearchTemplatePost<'_>
pub fn msearch_template_post(&self) -> MsearchTemplatePost<'_>
Allows to execute several search template operations in one request.
Sends a POST
request to /_msearch/template
Arguments:
ccs_minimize_roundtrips
: Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.max_concurrent_searches
: Controls the maximum number of concurrent searches the multi search api will execute.rest_total_hits_as_int
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.search_type
: Search operation type.typed_keys
: Specify whether aggregation and suggester names should be prefixed by their respective types in the response.body
let response = client.msearch_template_post()
.ccs_minimize_roundtrips(ccs_minimize_roundtrips)
.max_concurrent_searches(max_concurrent_searches)
.rest_total_hits_as_int(rest_total_hits_as_int)
.search_type(search_type)
.typed_keys(typed_keys)
.body(body)
.send()
.await;
Sourcepub fn rank_eval_get(&self) -> RankEvalGet<'_>
pub fn rank_eval_get(&self) -> RankEvalGet<'_>
Allows to evaluate the quality of ranked search results over a set of typical search queries.
Sends a GET
request to /_rank_eval
Arguments:
allow_no_indices
: 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
: Whether to expand wildcard expression to concrete indices that are open, closed or both.ignore_unavailable
: Whether specified concrete indices should be ignored when unavailable (missing or closed).search_type
: Search operation type.
let response = client.rank_eval_get()
.allow_no_indices(allow_no_indices)
.expand_wildcards(expand_wildcards)
.ignore_unavailable(ignore_unavailable)
.search_type(search_type)
.send()
.await;
Sourcepub fn rank_eval_post(&self) -> RankEvalPost<'_>
pub fn rank_eval_post(&self) -> RankEvalPost<'_>
Allows to evaluate the quality of ranked search results over a set of typical search queries.
Sends a POST
request to /_rank_eval
Arguments:
allow_no_indices
: 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
: Whether to expand wildcard expression to concrete indices that are open, closed or both.ignore_unavailable
: Whether specified concrete indices should be ignored when unavailable (missing or closed).search_type
: Search operation type.body
let response = client.rank_eval_post()
.allow_no_indices(allow_no_indices)
.expand_wildcards(expand_wildcards)
.ignore_unavailable(ignore_unavailable)
.search_type(search_type)
.body(body)
.send()
.await;
Sourcepub fn reindex(&self) -> Reindex<'_>
pub fn reindex(&self) -> Reindex<'_>
Allows to copy documents from one index to another, optionally filtering the source documents by a query, changing the destination index settings, or fetching the documents from a remote cluster.
Sends a POST
request to /_reindex
Arguments:
max_docs
: Maximum number of documents to process (default: all documents).refresh
: Should the affected indexes be refreshed?.requests_per_second
: The throttle for this request in sub-requests per second. -1 means no throttle.scroll
: Specify how long a consistent view of the index should be maintained for scrolled search.slices
: The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set toauto
.timeout
: Time each individual bulk request should wait for shards that are unavailable.wait_for_active_shards
: Sets the number of shard copies that must be active before proceeding with the operation. Defaults to 1, meaning the primary shard only. Set toall
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).wait_for_completion
: Should this request wait until the operation has completed before returning.body
let response = client.reindex()
.max_docs(max_docs)
.refresh(refresh)
.requests_per_second(requests_per_second)
.scroll(scroll)
.slices(slices)
.timeout(timeout)
.wait_for_active_shards(wait_for_active_shards)
.wait_for_completion(wait_for_completion)
.body(body)
.send()
.await;
Sourcepub fn reindex_rethrottle(&self) -> ReindexRethrottle<'_>
pub fn reindex_rethrottle(&self) -> ReindexRethrottle<'_>
Changes the number of requests per second for a particular Reindex operation.
Sends a POST
request to /_reindex/{task_id}/_rethrottle
Arguments:
task_id
: The task id to rethrottle.requests_per_second
: The throttle for this request in sub-requests per second. -1 means no throttle.
let response = client.reindex_rethrottle()
.task_id(task_id)
.requests_per_second(requests_per_second)
.send()
.await;
Sourcepub fn render_search_template_get(&self) -> RenderSearchTemplateGet<'_>
pub fn render_search_template_get(&self) -> RenderSearchTemplateGet<'_>
Allows to use the Mustache language to pre-render a search definition.
Sends a GET
request to /_render/template
let response = client.render_search_template_get()
.send()
.await;
Sourcepub fn render_search_template_post(&self) -> RenderSearchTemplatePost<'_>
pub fn render_search_template_post(&self) -> RenderSearchTemplatePost<'_>
Allows to use the Mustache language to pre-render a search definition.
Sends a POST
request to /_render/template
let response = client.render_search_template_post()
.body(body)
.send()
.await;
Sourcepub fn render_search_template_get_with_id(
&self,
) -> RenderSearchTemplateGetWithId<'_>
pub fn render_search_template_get_with_id( &self, ) -> RenderSearchTemplateGetWithId<'_>
Allows to use the Mustache language to pre-render a search definition.
Sends a GET
request to /_render/template/{id}
Arguments:
id
: The id of the stored search template.
let response = client.render_search_template_get_with_id()
.id(id)
.send()
.await;
Sourcepub fn render_search_template_post_with_id(
&self,
) -> RenderSearchTemplatePostWithId<'_>
pub fn render_search_template_post_with_id( &self, ) -> RenderSearchTemplatePostWithId<'_>
Allows to use the Mustache language to pre-render a search definition.
Sends a POST
request to /_render/template/{id}
Arguments:
id
: The id of the stored search template.body
let response = client.render_search_template_post_with_id()
.id(id)
.body(body)
.send()
.await;
Sourcepub fn get_script_context(&self) -> GetScriptContext<'_>
pub fn get_script_context(&self) -> GetScriptContext<'_>
Returns all script contexts.
Sends a GET
request to /_script_context
let response = client.get_script_context()
.send()
.await;
Sourcepub fn get_script_languages(&self) -> GetScriptLanguages<'_>
pub fn get_script_languages(&self) -> GetScriptLanguages<'_>
Returns available script types, languages and contexts.
Sends a GET
request to /_script_language
let response = client.get_script_languages()
.send()
.await;
Sourcepub fn scripts_painless_execute_get(&self) -> ScriptsPainlessExecuteGet<'_>
pub fn scripts_painless_execute_get(&self) -> ScriptsPainlessExecuteGet<'_>
Allows an arbitrary script to be executed and a result to be returned.
Sends a GET
request to /_scripts/painless/_execute
let response = client.scripts_painless_execute_get()
.send()
.await;
Sourcepub fn scripts_painless_execute_post(&self) -> ScriptsPainlessExecutePost<'_>
pub fn scripts_painless_execute_post(&self) -> ScriptsPainlessExecutePost<'_>
Allows an arbitrary script to be executed and a result to be returned.
Sends a POST
request to /_scripts/painless/_execute
let response = client.scripts_painless_execute_post()
.body(body)
.send()
.await;
Sourcepub fn get_script(&self) -> GetScript<'_>
pub fn get_script(&self) -> GetScript<'_>
Returns a script.
Sends a GET
request to /_scripts/{id}
Arguments:
id
: Script ID.cluster_manager_timeout
: Operation timeout for connection to cluster-manager node.master_timeout
: Operation timeout for connection to master node.
let response = client.get_script()
.id(id)
.cluster_manager_timeout(cluster_manager_timeout)
.master_timeout(master_timeout)
.send()
.await;
Sourcepub fn put_script_put(&self) -> PutScriptPut<'_>
pub fn put_script_put(&self) -> PutScriptPut<'_>
Creates or updates a script.
Sends a PUT
request to /_scripts/{id}
Arguments:
id
: Script ID.cluster_manager_timeout
: Operation timeout for connection to cluster-manager node.master_timeout
: Operation timeout for connection to master node.timeout
: Operation timeout.body
let response = client.put_script_put()
.id(id)
.cluster_manager_timeout(cluster_manager_timeout)
.master_timeout(master_timeout)
.timeout(timeout)
.body(body)
.send()
.await;
Sourcepub fn put_script_post(&self) -> PutScriptPost<'_>
pub fn put_script_post(&self) -> PutScriptPost<'_>
Creates or updates a script.
Sends a POST
request to /_scripts/{id}
Arguments:
id
: Script ID.cluster_manager_timeout
: Operation timeout for connection to cluster-manager node.master_timeout
: Operation timeout for connection to master node.timeout
: Operation timeout.body
let response = client.put_script_post()
.id(id)
.cluster_manager_timeout(cluster_manager_timeout)
.master_timeout(master_timeout)
.timeout(timeout)
.body(body)
.send()
.await;
Sourcepub fn delete_script(&self) -> DeleteScript<'_>
pub fn delete_script(&self) -> DeleteScript<'_>
Deletes a script.
Sends a DELETE
request to /_scripts/{id}
Arguments:
id
: Script ID.cluster_manager_timeout
: Operation timeout for connection to cluster-manager node.master_timeout
: Operation timeout for connection to master node.timeout
: Operation timeout.
let response = client.delete_script()
.id(id)
.cluster_manager_timeout(cluster_manager_timeout)
.master_timeout(master_timeout)
.timeout(timeout)
.send()
.await;
Sourcepub fn put_script_put_with_context(&self) -> PutScriptPutWithContext<'_>
pub fn put_script_put_with_context(&self) -> PutScriptPutWithContext<'_>
Creates or updates a script.
Sends a PUT
request to /_scripts/{id}/{context}
Arguments:
id
: Script ID.context
: Script context.cluster_manager_timeout
: Operation timeout for connection to cluster-manager node.master_timeout
: Operation timeout for connection to master node.timeout
: Operation timeout.body
let response = client.put_script_put_with_context()
.id(id)
.context(context)
.cluster_manager_timeout(cluster_manager_timeout)
.master_timeout(master_timeout)
.timeout(timeout)
.body(body)
.send()
.await;
Sourcepub fn put_script_post_with_context(&self) -> PutScriptPostWithContext<'_>
pub fn put_script_post_with_context(&self) -> PutScriptPostWithContext<'_>
Creates or updates a script.
Sends a POST
request to /_scripts/{id}/{context}
Arguments:
id
: Script ID.context
: Script context.cluster_manager_timeout
: Operation timeout for connection to cluster-manager node.master_timeout
: Operation timeout for connection to master node.timeout
: Operation timeout.body
let response = client.put_script_post_with_context()
.id(id)
.context(context)
.cluster_manager_timeout(cluster_manager_timeout)
.master_timeout(master_timeout)
.timeout(timeout)
.body(body)
.send()
.await;
Sourcepub fn delete_pit(&self) -> DeletePit<'_>
pub fn delete_pit(&self) -> DeletePit<'_>
Deletes one or more point in time searches based on the IDs passed.
Sends a DELETE
request to /_search/point_in_time
let response = client.delete_pit()
.body(body)
.send()
.await;
Sourcepub fn get_all_pits(&self) -> GetAllPits<'_>
pub fn get_all_pits(&self) -> GetAllPits<'_>
Lists all active point in time searches.
Sends a GET
request to /_search/point_in_time/_all
let response = client.get_all_pits()
.send()
.await;
Sourcepub fn delete_all_pits(&self) -> DeleteAllPits<'_>
pub fn delete_all_pits(&self) -> DeleteAllPits<'_>
Deletes all active point in time searches.
Sends a DELETE
request to /_search/point_in_time/_all
let response = client.delete_all_pits()
.send()
.await;
Sourcepub fn scroll_get(&self) -> ScrollGet<'_>
pub fn scroll_get(&self) -> ScrollGet<'_>
Allows to retrieve a large numbers of results from a single search request.
Sends a GET
request to /_search/scroll
Arguments:
rest_total_hits_as_int
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.scroll
: Specify how long a consistent view of the index should be maintained for scrolled search.scroll_id
: Scroll ID.
let response = client.scroll_get()
.rest_total_hits_as_int(rest_total_hits_as_int)
.scroll(scroll)
.scroll_id(scroll_id)
.send()
.await;
Sourcepub fn scroll_post(&self) -> ScrollPost<'_>
pub fn scroll_post(&self) -> ScrollPost<'_>
Allows to retrieve a large numbers of results from a single search request.
Sends a POST
request to /_search/scroll
Arguments:
rest_total_hits_as_int
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.scroll
: Specify how long a consistent view of the index should be maintained for scrolled search.scroll_id
: Scroll ID.body
let response = client.scroll_post()
.rest_total_hits_as_int(rest_total_hits_as_int)
.scroll(scroll)
.scroll_id(scroll_id)
.body(body)
.send()
.await;
Sourcepub fn clear_scroll(&self) -> ClearScroll<'_>
pub fn clear_scroll(&self) -> ClearScroll<'_>
Explicitly clears the search context for a scroll.
Sends a DELETE
request to /_search/scroll
let response = client.clear_scroll()
.body(body)
.send()
.await;
Sourcepub fn scroll_get_with_scroll_id(&self) -> ScrollGetWithScrollId<'_>
pub fn scroll_get_with_scroll_id(&self) -> ScrollGetWithScrollId<'_>
Allows to retrieve a large numbers of results from a single search request.
Sends a GET
request to /_search/scroll/{scroll_id}
Arguments:
rest_total_hits_as_int
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.scroll
: Specify how long a consistent view of the index should be maintained for scrolled search.scroll_id
: Scroll ID.
let response = client.scroll_get_with_scroll_id()
.rest_total_hits_as_int(rest_total_hits_as_int)
.scroll(scroll)
.scroll_id(scroll_id)
.send()
.await;
Sourcepub fn scroll_post_with_scroll_id(&self) -> ScrollPostWithScrollId<'_>
pub fn scroll_post_with_scroll_id(&self) -> ScrollPostWithScrollId<'_>
Allows to retrieve a large numbers of results from a single search request.
Sends a POST
request to /_search/scroll/{scroll_id}
Arguments:
rest_total_hits_as_int
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.scroll
: Specify how long a consistent view of the index should be maintained for scrolled search.scroll_id
: Scroll ID.body
let response = client.scroll_post_with_scroll_id()
.rest_total_hits_as_int(rest_total_hits_as_int)
.scroll(scroll)
.scroll_id(scroll_id)
.body(body)
.send()
.await;
Sourcepub fn clear_scroll_with_scroll_id(&self) -> ClearScrollWithScrollId<'_>
pub fn clear_scroll_with_scroll_id(&self) -> ClearScrollWithScrollId<'_>
Explicitly clears the search context for a scroll.
Sends a DELETE
request to /_search/scroll/{scroll_id}
Arguments:
scroll_id
: Comma-separated list of scroll IDs to clear.body
let response = client.clear_scroll_with_scroll_id()
.scroll_id(scroll_id)
.body(body)
.send()
.await;
Sourcepub fn update_by_query_rethrottle(&self) -> UpdateByQueryRethrottle<'_>
pub fn update_by_query_rethrottle(&self) -> UpdateByQueryRethrottle<'_>
Changes the number of requests per second for a particular Update By Query operation.
Sends a POST
request to /_update_by_query/{task_id}/_rethrottle
Arguments:
task_id
: The task id to rethrottle.requests_per_second
: The throttle for this request in sub-requests per second. -1 means no throttle.
let response = client.update_by_query_rethrottle()
.task_id(task_id)
.requests_per_second(requests_per_second)
.send()
.await;
Sourcepub fn create_put(&self) -> CreatePut<'_>
pub fn create_put(&self) -> CreatePut<'_>
Creates a new document in the index.
Returns a 409 response when a document with a same ID already exists in the index.
Sends a PUT
request to /{index}/_create/{id}
Arguments:
index
: Index name.id
: Document ID.pipeline
: The pipeline id to preprocess incoming documents with.refresh
: Iftrue
then refresh the affected shards to make this operation visible to search, ifwait_for
then wait for a refresh to make this operation visible to search, iffalse
(the default) then do nothing with refreshes.routing
: Routing value.timeout
: Operation timeout.version
: Explicit version number for concurrency control.version_type
: Specific version type.wait_for_active_shards
: Sets the number of shard copies that must be active before proceeding with the operation. Defaults to 1, meaning the primary shard only. Set toall
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).body
let response = client.create_put()
.index(index)
.id(id)
.pipeline(pipeline)
.refresh(refresh)
.routing(routing)
.timeout(timeout)
.version(version)
.version_type(version_type)
.wait_for_active_shards(wait_for_active_shards)
.body(body)
.send()
.await;
Sourcepub fn delete_by_query(&self) -> DeleteByQuery<'_>
pub fn delete_by_query(&self) -> DeleteByQuery<'_>
Deletes documents matching the provided query.
Sends a POST
request to /{index}/_delete_by_query
Arguments:
index
: Comma-separated list of indices; use_all
or empty string to perform the operation on all indices.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.allow_no_indices
: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes_all
string or when no indices have been specified).analyze_wildcard
: Specify whether wildcard and prefix queries should be analyzed.analyzer
: The analyzer to use for the query string.conflicts
: What to do when the operation encounters version conflicts?.default_operator
: The default operator for query string query (AND or OR).df
: The field to use as default where no field prefix is given in the query string.expand_wildcards
: Whether to expand wildcard expression to concrete indices that are open, closed or both.from
: Starting offset.ignore_unavailable
: Whether specified concrete indices should be ignored when unavailable (missing or closed).lenient
: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.max_docs
: Maximum number of documents to process (default: all documents).preference
: Specify the node or shard the operation should be performed on.q
: Query in the Lucene query string syntax.refresh
: Refresh the shard containing the document before performing the operation.request_cache
: Specify if request cache should be used for this request or not, defaults to index level setting.requests_per_second
: The throttle for this request in sub-requests per second. -1 means no throttle.routing
: Comma-separated list of specific routing values.scroll
: Specify how long a consistent view of the index should be maintained for scrolled search.scroll_size
: Size on the scroll request powering the operation.search_timeout
: Explicit timeout for each search request. Defaults to no timeout.search_type
: Search operation type.size
: Deprecated, please usemax_docs
instead.slices
: The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set toauto
.sort
: Comma-separated list of: pairs. stats
: Specific ‘tag’ of the request for logging and statistical purposes.terminate_after
: The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.timeout
: Time each individual bulk request should wait for shards that are unavailable.version
: Whether to return document version as part of a hit.wait_for_active_shards
: Sets the number of shard copies that must be active before proceeding with the operation. Defaults to 1, meaning the primary shard only. Set toall
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).wait_for_completion
: Should this request wait until the operation has completed before returning.body
let response = client.delete_by_query()
.index(index)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.allow_no_indices(allow_no_indices)
.analyze_wildcard(analyze_wildcard)
.analyzer(analyzer)
.conflicts(conflicts)
.default_operator(default_operator)
.df(df)
.expand_wildcards(expand_wildcards)
.from(from)
.ignore_unavailable(ignore_unavailable)
.lenient(lenient)
.max_docs(max_docs)
.preference(preference)
.q(q)
.refresh(refresh)
.request_cache(request_cache)
.requests_per_second(requests_per_second)
.routing(routing)
.scroll(scroll)
.scroll_size(scroll_size)
.search_timeout(search_timeout)
.search_type(search_type)
.size(size)
.slices(slices)
.sort(sort)
.stats(stats)
.terminate_after(terminate_after)
.timeout(timeout)
.version(version)
.wait_for_active_shards(wait_for_active_shards)
.wait_for_completion(wait_for_completion)
.body(body)
.send()
.await;
Sourcepub fn get(&self) -> Get<'_>
pub fn get(&self) -> Get<'_>
Returns a document.
Sends a GET
request to /{index}/_doc/{id}
Arguments:
index
: Index name.id
: Document ID.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.preference
: Specify the node or shard the operation should be performed on.realtime
: Specify whether to perform the operation in realtime or search mode.refresh
: Refresh the shard containing the document before performing the operation.routing
: Routing value.stored_fields
: Comma-separated list of stored fields to return.version
: Explicit version number for concurrency control.version_type
: Specific version type.
let response = client.get()
.index(index)
.id(id)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.preference(preference)
.realtime(realtime)
.refresh(refresh)
.routing(routing)
.stored_fields(stored_fields)
.version(version)
.version_type(version_type)
.send()
.await;
Sourcepub fn index_put_with_id(&self) -> IndexPutWithId<'_>
pub fn index_put_with_id(&self) -> IndexPutWithId<'_>
Creates or updates a document in an index.
Sends a PUT
request to /{index}/_doc/{id}
Arguments:
index
: Index name.id
: Document ID.if_primary_term
: only perform the operation if the last operation that has changed the document has the specified primary term.if_seq_no
: only perform the operation if the last operation that has changed the document has the specified sequence number.op_type
: Explicit operation type. Defaults toindex
for requests with an explicit document ID, and tocreate
for requests without an explicit document ID.pipeline
: The pipeline id to preprocess incoming documents with.refresh
: Iftrue
then refresh the affected shards to make this operation visible to search, ifwait_for
then wait for a refresh to make this operation visible to search, iffalse
(the default) then do nothing with refreshes.require_alias
: When true, requires destination to be an alias.routing
: Routing value.timeout
: Operation timeout.version
: Explicit version number for concurrency control.version_type
: Specific version type.wait_for_active_shards
: Sets the number of shard copies that must be active before proceeding with the operation. Defaults to 1, meaning the primary shard only. Set toall
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).body
let response = client.index_put_with_id()
.index(index)
.id(id)
.if_primary_term(if_primary_term)
.if_seq_no(if_seq_no)
.op_type(op_type)
.pipeline(pipeline)
.refresh(refresh)
.require_alias(require_alias)
.routing(routing)
.timeout(timeout)
.version(version)
.version_type(version_type)
.wait_for_active_shards(wait_for_active_shards)
.body(body)
.send()
.await;
Sourcepub fn index_post(&self) -> IndexPost<'_>
pub fn index_post(&self) -> IndexPost<'_>
Creates or updates a document in an index.
Sends a POST
request to /{index}/_doc/{id}
Arguments:
index
: Index name.id
: Document ID.if_primary_term
: only perform the operation if the last operation that has changed the document has the specified primary term.if_seq_no
: only perform the operation if the last operation that has changed the document has the specified sequence number.op_type
: Explicit operation type. Defaults toindex
for requests with an explicit document ID, and tocreate
for requests without an explicit document ID.pipeline
: The pipeline id to preprocess incoming documents with.refresh
: Iftrue
then refresh the affected shards to make this operation visible to search, ifwait_for
then wait for a refresh to make this operation visible to search, iffalse
(the default) then do nothing with refreshes.require_alias
: When true, requires destination to be an alias.routing
: Routing value.timeout
: Operation timeout.version
: Explicit version number for concurrency control.version_type
: Specific version type.wait_for_active_shards
: Sets the number of shard copies that must be active before proceeding with the operation. Defaults to 1, meaning the primary shard only. Set toall
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).body
let response = client.index_post_with_id()
.index(index)
.id(id)
.if_primary_term(if_primary_term)
.if_seq_no(if_seq_no)
.op_type(op_type)
.pipeline(pipeline)
.refresh(refresh)
.require_alias(require_alias)
.routing(routing)
.timeout(timeout)
.version(version)
.version_type(version_type)
.wait_for_active_shards(wait_for_active_shards)
.body(body)
.send()
.await;
Sourcepub fn delete(&self) -> Delete<'_>
pub fn delete(&self) -> Delete<'_>
Removes a document from the index.
Sends a DELETE
request to /{index}/_doc/{id}
Arguments:
index
: Index name.id
: Document ID.if_primary_term
: only perform the operation if the last operation that has changed the document has the specified primary term.if_seq_no
: only perform the operation if the last operation that has changed the document has the specified sequence number.refresh
: Iftrue
then refresh the affected shards to make this operation visible to search, ifwait_for
then wait for a refresh to make this operation visible to search, iffalse
(the default) then do nothing with refreshes.routing
: Routing value.timeout
: Operation timeout.version
: Explicit version number for concurrency control.version_type
: Specific version type.wait_for_active_shards
: Sets the number of shard copies that must be active before proceeding with the operation. Defaults to 1, meaning the primary shard only. Set toall
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).
let response = client.delete()
.index(index)
.id(id)
.if_primary_term(if_primary_term)
.if_seq_no(if_seq_no)
.refresh(refresh)
.routing(routing)
.timeout(timeout)
.version(version)
.version_type(version_type)
.wait_for_active_shards(wait_for_active_shards)
.send()
.await;
Sourcepub fn exists(&self) -> Exists<'_>
pub fn exists(&self) -> Exists<'_>
Returns information about whether a document exists in an index.
Sends a HEAD
request to /{index}/_doc/{id}
Arguments:
index
: Index name.id
: Document ID.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.preference
: Specify the node or shard the operation should be performed on.realtime
: Specify whether to perform the operation in realtime or search mode.refresh
: Refresh the shard containing the document before performing the operation.routing
: Routing value.stored_fields
: Comma-separated list of stored fields to return.version
: Explicit version number for concurrency control.version_type
: Specific version type.
let response = client.exists()
.index(index)
.id(id)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.preference(preference)
.realtime(realtime)
.refresh(refresh)
.routing(routing)
.stored_fields(stored_fields)
.version(version)
.version_type(version_type)
.send()
.await;
Sourcepub fn explain(&self) -> ExplainPost<'_>
pub fn explain(&self) -> ExplainPost<'_>
Returns information about why a specific matches (or doesn’t match) a query.
Sends a POST
request to /{index}/_explain/{id}
Arguments:
index
: Index name.id
: Document ID.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.analyze_wildcard
: Specify whether wildcards and prefix queries in the query string query should be analyzed.analyzer
: The analyzer to use for the query string.default_operator
: The default operator for query string query (AND or OR).df
: The default field for query string query.lenient
: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.preference
: Specify the node or shard the operation should be performed on.q
: Query in the Lucene query string syntax.routing
: Routing value.stored_fields
: Comma-separated list of stored fields to return.body
let response = client.explain()
.index(index)
.id(id)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.analyze_wildcard(analyze_wildcard)
.analyzer(analyzer)
.default_operator(default_operator)
.df(df)
.lenient(lenient)
.preference(preference)
.q(q)
.routing(routing)
.stored_fields(stored_fields)
.body(body)
.send()
.await;
Sourcepub fn field_caps_get_with_index(&self) -> FieldCapsGetWithIndex<'_>
pub fn field_caps_get_with_index(&self) -> FieldCapsGetWithIndex<'_>
Returns the information about the capabilities of fields among multiple indices.
Sends a GET
request to /{index}/_field_caps
Arguments:
index
: Comma-separated list of indices; use_all
or empty string to perform the operation on all indices.allow_no_indices
: 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
: Whether to expand wildcard expression to concrete indices that are open, closed or both.fields
: Comma-separated list of field names.ignore_unavailable
: Whether specified concrete indices should be ignored when unavailable (missing or closed).include_unmapped
: Indicates whether unmapped fields should be included in the response.
let response = client.field_caps_get_with_index()
.index(index)
.allow_no_indices(allow_no_indices)
.expand_wildcards(expand_wildcards)
.fields(fields)
.ignore_unavailable(ignore_unavailable)
.include_unmapped(include_unmapped)
.send()
.await;
Sourcepub fn field_caps_post_with_index(&self) -> FieldCapsPostWithIndex<'_>
pub fn field_caps_post_with_index(&self) -> FieldCapsPostWithIndex<'_>
Returns the information about the capabilities of fields among multiple indices.
Sends a POST
request to /{index}/_field_caps
Arguments:
index
: Comma-separated list of indices; use_all
or empty string to perform the operation on all indices.allow_no_indices
: 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
: Whether to expand wildcard expression to concrete indices that are open, closed or both.fields
: Comma-separated list of field names.ignore_unavailable
: Whether specified concrete indices should be ignored when unavailable (missing or closed).include_unmapped
: Indicates whether unmapped fields should be included in the response.body
let response = client.field_caps_post_with_index()
.index(index)
.allow_no_indices(allow_no_indices)
.expand_wildcards(expand_wildcards)
.fields(fields)
.ignore_unavailable(ignore_unavailable)
.include_unmapped(include_unmapped)
.body(body)
.send()
.await;
Sourcepub fn mget_get_with_index(&self) -> MgetGetWithIndex<'_>
pub fn mget_get_with_index(&self) -> MgetGetWithIndex<'_>
Allows to get multiple documents in one request.
Sends a GET
request to /{index}/_mget
Arguments:
index
: Index name.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.preference
: Specify the node or shard the operation should be performed on.realtime
: Specify whether to perform the operation in realtime or search mode.refresh
: Refresh the shard containing the document before performing the operation.routing
: Routing value.stored_fields
: Comma-separated list of stored fields to return.
let response = client.mget_get_with_index()
.index(index)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.preference(preference)
.realtime(realtime)
.refresh(refresh)
.routing(routing)
.stored_fields(stored_fields)
.send()
.await;
Sourcepub fn mget_with_index(&self) -> MgetWithIndex<'_>
pub fn mget_with_index(&self) -> MgetWithIndex<'_>
Allows to get multiple documents in one request.
Sends a POST
request to /{index}/_mget
Arguments:
index
: Index name.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.preference
: Specify the node or shard the operation should be performed on.realtime
: Specify whether to perform the operation in realtime or search mode.refresh
: Refresh the shard containing the document before performing the operation.routing
: Routing value.stored_fields
: Comma-separated list of stored fields to return.body
let response = client.mget_with_index()
.index(index)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.preference(preference)
.realtime(realtime)
.refresh(refresh)
.routing(routing)
.stored_fields(stored_fields)
.body(body)
.send()
.await;
Sourcepub fn msearch_post_with_index(&self) -> MsearchPostWithIndex<'_>
pub fn msearch_post_with_index(&self) -> MsearchPostWithIndex<'_>
Allows to execute several search operations in one request.
Sends a POST
request to /{index}/_msearch
Arguments:
index
: Comma-separated list of indices to use as default.ccs_minimize_roundtrips
: Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.max_concurrent_searches
: Controls the maximum number of concurrent searches the multi search api will execute.max_concurrent_shard_requests
: The number of concurrent shard requests each sub search executes concurrently per node. 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
: Threshold that enforces a pre-filter round-trip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter round-trip 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
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.search_type
: Search operation type.typed_keys
: Specify whether aggregation and suggester names should be prefixed by their respective types in the response.body
let response = client.msearch_post_with_index()
.index(index)
.ccs_minimize_roundtrips(ccs_minimize_roundtrips)
.max_concurrent_searches(max_concurrent_searches)
.max_concurrent_shard_requests(max_concurrent_shard_requests)
.pre_filter_shard_size(pre_filter_shard_size)
.rest_total_hits_as_int(rest_total_hits_as_int)
.search_type(search_type)
.typed_keys(typed_keys)
.body(body)
.send()
.await;
Sourcepub fn msearch_template_with_index(&self) -> MsearchTemplatePostWithIndex<'_>
pub fn msearch_template_with_index(&self) -> MsearchTemplatePostWithIndex<'_>
Allows to execute several search template operations in one request.
Sends a POST
request to /{index}/_msearch/template
Arguments:
index
: Comma-separated list of indices to use as default.ccs_minimize_roundtrips
: Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.max_concurrent_searches
: Controls the maximum number of concurrent searches the multi search api will execute.rest_total_hits_as_int
: Indicates whether hits.total should be rendered as an integer or an object in the rest search response.search_type
: Search operation type.typed_keys
: Specify whether aggregation and suggester names should be prefixed by their respective types in the response.body
let response = client.msearch_template_with_index()
.index(index)
.ccs_minimize_roundtrips(ccs_minimize_roundtrips)
.max_concurrent_searches(max_concurrent_searches)
.rest_total_hits_as_int(rest_total_hits_as_int)
.search_type(search_type)
.typed_keys(typed_keys)
.body(body)
.send()
.await;
Sourcepub fn rank_eval_post_with_index(&self) -> RankEvalPostWithIndex<'_>
pub fn rank_eval_post_with_index(&self) -> RankEvalPostWithIndex<'_>
Allows to evaluate the quality of ranked search results over a set of typical search queries.
Sends a POST
request to /{index}/_rank_eval
Arguments:
index
: Comma-separated list of indices; use_all
or empty string to perform the operation on all indices.allow_no_indices
: 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
: Whether to expand wildcard expression to concrete indices that are open, closed or both.ignore_unavailable
: Whether specified concrete indices should be ignored when unavailable (missing or closed).search_type
: Search operation type.body
let response = client.rank_eval_post_with_index()
.index(index)
.allow_no_indices(allow_no_indices)
.expand_wildcards(expand_wildcards)
.ignore_unavailable(ignore_unavailable)
.search_type(search_type)
.body(body)
.send()
.await;
Sourcepub fn create_pit(&self) -> CreatePit<'_>
pub fn create_pit(&self) -> CreatePit<'_>
Creates point in time context.
Sends a POST
request to /{index}/_search/point_in_time
Arguments:
index
: Comma-separated list of indices; use_all
or empty string to perform the operation on all indices.allow_partial_pit_creation
: Allow if point in time can be created with partial failures.expand_wildcards
: Whether to expand wildcard expression to concrete indices that are open, closed or both.keep_alive
: Specify the keep alive for point in time.preference
: Specify the node or shard the operation should be performed on.routing
: Comma-separated list of specific routing values.
let response = client.create_pit()
.index(index)
.allow_partial_pit_creation(allow_partial_pit_creation)
.expand_wildcards(expand_wildcards)
.keep_alive(keep_alive)
.preference(preference)
.routing(routing)
.send()
.await;
Sourcepub fn get_source(&self) -> GetSource<'_>
pub fn get_source(&self) -> GetSource<'_>
Returns the source of a document.
Sends a GET
request to /{index}/_source/{id}
Arguments:
index
: Index name.id
: Document ID.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.preference
: Specify the node or shard the operation should be performed on.realtime
: Specify whether to perform the operation in realtime or search mode.refresh
: Refresh the shard containing the document before performing the operation.routing
: Routing value.version
: Explicit version number for concurrency control.version_type
: Specific version type.
let response = client.get_source()
.index(index)
.id(id)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.preference(preference)
.realtime(realtime)
.refresh(refresh)
.routing(routing)
.version(version)
.version_type(version_type)
.send()
.await;
Sourcepub fn exists_source(&self) -> ExistsSource<'_>
pub fn exists_source(&self) -> ExistsSource<'_>
Returns information about whether a document source exists in an index.
Sends a HEAD
request to /{index}/_source/{id}
Arguments:
index
: Index name.id
: Document ID.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.preference
: Specify the node or shard the operation should be performed on.realtime
: Specify whether to perform the operation in realtime or search mode.refresh
: Refresh the shard containing the document before performing the operation.routing
: Routing value.version
: Explicit version number for concurrency control.version_type
: Specific version type.
let response = client.exists_source()
.index(index)
.id(id)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.preference(preference)
.realtime(realtime)
.refresh(refresh)
.routing(routing)
.version(version)
.version_type(version_type)
.send()
.await;
Sourcepub fn termvectors_get(&self) -> TermvectorsGet<'_>
pub fn termvectors_get(&self) -> TermvectorsGet<'_>
Returns information and statistics about terms in the fields of a particular document.
Sends a GET
request to /{index}/_termvectors
Arguments:
index
: The index in which the document resides.field_statistics
: Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.fields
: Comma-separated list of fields to return.offsets
: Specifies if term offsets should be returned.payloads
: Specifies if term payloads should be returned.positions
: Specifies if term positions should be returned.preference
: Specify the node or shard the operation should be performed on.realtime
: Specifies if request is real-time as opposed to near-real-time.routing
: Routing value.term_statistics
: Specifies if total term frequency and document frequency should be returned.version
: Explicit version number for concurrency control.version_type
: Specific version type.
let response = client.termvectors_get()
.index(index)
.field_statistics(field_statistics)
.fields(fields)
.offsets(offsets)
.payloads(payloads)
.positions(positions)
.preference(preference)
.realtime(realtime)
.routing(routing)
.term_statistics(term_statistics)
.version(version)
.version_type(version_type)
.send()
.await;
Sourcepub fn termvectors_post(&self) -> TermvectorsPost<'_>
pub fn termvectors_post(&self) -> TermvectorsPost<'_>
Returns information and statistics about terms in the fields of a particular document.
Sends a POST
request to /{index}/_termvectors
Arguments:
index
: The index in which the document resides.field_statistics
: Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.fields
: Comma-separated list of fields to return.offsets
: Specifies if term offsets should be returned.payloads
: Specifies if term payloads should be returned.positions
: Specifies if term positions should be returned.preference
: Specify the node or shard the operation should be performed on.realtime
: Specifies if request is real-time as opposed to near-real-time.routing
: Routing value.term_statistics
: Specifies if total term frequency and document frequency should be returned.version
: Explicit version number for concurrency control.version_type
: Specific version type.body
let response = client.termvectors_post()
.index(index)
.field_statistics(field_statistics)
.fields(fields)
.offsets(offsets)
.payloads(payloads)
.positions(positions)
.preference(preference)
.realtime(realtime)
.routing(routing)
.term_statistics(term_statistics)
.version(version)
.version_type(version_type)
.body(body)
.send()
.await;
Sourcepub fn termvectors_get_with_id(&self) -> TermvectorsGetWithId<'_>
pub fn termvectors_get_with_id(&self) -> TermvectorsGetWithId<'_>
Returns information and statistics about terms in the fields of a particular document.
Sends a GET
request to /{index}/_termvectors/{id}
Arguments:
index
: The index in which the document resides.id
: Document ID. When not specified a doc param should be supplied.field_statistics
: Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.fields
: Comma-separated list of fields to return.offsets
: Specifies if term offsets should be returned.payloads
: Specifies if term payloads should be returned.positions
: Specifies if term positions should be returned.preference
: Specify the node or shard the operation should be performed on.realtime
: Specifies if request is real-time as opposed to near-real-time.routing
: Routing value.term_statistics
: Specifies if total term frequency and document frequency should be returned.version
: Explicit version number for concurrency control.version_type
: Specific version type.
let response = client.termvectors_get_with_id()
.index(index)
.id(id)
.field_statistics(field_statistics)
.fields(fields)
.offsets(offsets)
.payloads(payloads)
.positions(positions)
.preference(preference)
.realtime(realtime)
.routing(routing)
.term_statistics(term_statistics)
.version(version)
.version_type(version_type)
.send()
.await;
Sourcepub fn termvectors_post_with_id(&self) -> TermvectorsPostWithId<'_>
pub fn termvectors_post_with_id(&self) -> TermvectorsPostWithId<'_>
Returns information and statistics about terms in the fields of a particular document.
Sends a POST
request to /{index}/_termvectors/{id}
Arguments:
index
: The index in which the document resides.id
: Document ID. When not specified a doc param should be supplied.field_statistics
: Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.fields
: Comma-separated list of fields to return.offsets
: Specifies if term offsets should be returned.payloads
: Specifies if term payloads should be returned.positions
: Specifies if term positions should be returned.preference
: Specify the node or shard the operation should be performed on.realtime
: Specifies if request is real-time as opposed to near-real-time.routing
: Routing value.term_statistics
: Specifies if total term frequency and document frequency should be returned.version
: Explicit version number for concurrency control.version_type
: Specific version type.body
let response = client.termvectors_post_with_id()
.index(index)
.id(id)
.field_statistics(field_statistics)
.fields(fields)
.offsets(offsets)
.payloads(payloads)
.positions(positions)
.preference(preference)
.realtime(realtime)
.routing(routing)
.term_statistics(term_statistics)
.version(version)
.version_type(version_type)
.body(body)
.send()
.await;
Sourcepub fn update(&self) -> Update<'_>
pub fn update(&self) -> Update<'_>
Updates a document with a script or partial document.
Sends a POST
request to /{index}/_update/{id}
Arguments:
index
: Index name.id
: Document ID.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.if_primary_term
: only perform the operation if the last operation that has changed the document has the specified primary term.if_seq_no
: only perform the operation if the last operation that has changed the document has the specified sequence number.lang
: The script language.refresh
: Iftrue
then refresh the affected shards to make this operation visible to search, ifwait_for
then wait for a refresh to make this operation visible to search, iffalse
(the default) then do nothing with refreshes.require_alias
: When true, requires destination to be an alias.retry_on_conflict
: Specify how many times should the operation be retried when a conflict occurs.routing
: Routing value.timeout
: Operation timeout.wait_for_active_shards
: Sets the number of shard copies that must be active before proceeding with the operation. Defaults to 1, meaning the primary shard only. Set toall
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).body
let response = client.update()
.index(index)
.id(id)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.if_primary_term(if_primary_term)
.if_seq_no(if_seq_no)
.lang(lang)
.refresh(refresh)
.require_alias(require_alias)
.retry_on_conflict(retry_on_conflict)
.routing(routing)
.timeout(timeout)
.wait_for_active_shards(wait_for_active_shards)
.body(body)
.send()
.await;
Sourcepub fn update_by_query(&self) -> UpdateByQuery<'_>
pub fn update_by_query(&self) -> UpdateByQuery<'_>
Performs an update on every document in the index without changing the source, for example to pick up a mapping change.
Sends a POST
request to /{index}/_update_by_query
Arguments:
index
: Comma-separated list of indices; use_all
or empty string to perform the operation on all indices.source
: True or false to return the _source field or not, or a list of fields to return.source_excludes
: List of fields to exclude from the returned _source field.source_includes
: List of fields to extract and return from the _source field.allow_no_indices
: Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes_all
string or when no indices have been specified).analyze_wildcard
: Specify whether wildcard and prefix queries should be analyzed.analyzer
: The analyzer to use for the query string.conflicts
: What to do when the operation encounters version conflicts?.default_operator
: The default operator for query string query (AND or OR).df
: The field to use as default where no field prefix is given in the query string.expand_wildcards
: Whether to expand wildcard expression to concrete indices that are open, closed or both.from
: Starting offset.ignore_unavailable
: Whether specified concrete indices should be ignored when unavailable (missing or closed).lenient
: Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.max_docs
: Maximum number of documents to process (default: all documents).pipeline
: The pipeline id to preprocess incoming documents with.preference
: Specify the node or shard the operation should be performed on.q
: Query in the Lucene query string syntax.refresh
: Should the affected indexes be refreshed?.request_cache
: Specify if request cache should be used for this request or not, defaults to index level setting.requests_per_second
: The throttle for this request in sub-requests per second. -1 means no throttle.routing
: Comma-separated list of specific routing values.scroll
: Specify how long a consistent view of the index should be maintained for scrolled search.scroll_size
: Size on the scroll request powering the operation.search_timeout
: Explicit timeout for each search request. Defaults to no timeout.search_type
: Search operation type.size
: Deprecated, please usemax_docs
instead.slices
: The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set toauto
.sort
: Comma-separated list of: pairs. stats
: Specific ‘tag’ of the request for logging and statistical purposes.terminate_after
: The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.timeout
: Time each individual bulk request should wait for shards that are unavailable.version
: Whether to return document version as part of a hit.wait_for_active_shards
: Sets the number of shard copies that must be active before proceeding with the operation. Defaults to 1, meaning the primary shard only. Set toall
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).wait_for_completion
: Should this request wait until the operation has completed before returning.body
let response = client.update_by_query()
.index(index)
.source(source)
.source_excludes(source_excludes)
.source_includes(source_includes)
.allow_no_indices(allow_no_indices)
.analyze_wildcard(analyze_wildcard)
.analyzer(analyzer)
.conflicts(conflicts)
.default_operator(default_operator)
.df(df)
.expand_wildcards(expand_wildcards)
.from(from)
.ignore_unavailable(ignore_unavailable)
.lenient(lenient)
.max_docs(max_docs)
.pipeline(pipeline)
.preference(preference)
.q(q)
.refresh(refresh)
.request_cache(request_cache)
.requests_per_second(requests_per_second)
.routing(routing)
.scroll(scroll)
.scroll_size(scroll_size)
.search_timeout(search_timeout)
.search_type(search_type)
.size(size)
.slices(slices)
.sort(sort)
.stats(stats)
.terminate_after(terminate_after)
.timeout(timeout)
.version(version)
.wait_for_active_shards(wait_for_active_shards)
.wait_for_completion(wait_for_completion)
.body(body)
.send()
.await;
Sourcepub async fn bulk_index_document<T: Serialize>(
&self,
index: &str,
id: Option<String>,
body: &T,
) -> Result<(), Error>
pub async fn bulk_index_document<T: Serialize>( &self, index: &str, id: Option<String>, body: &T, ) -> Result<(), Error>
Sends a bulk index request to OpenSearch with the specified index, id and document body.
§Arguments
index
- A string slice that holds the name of the index.id
- An optional string slice that holds the id of the document.body
- A reference to a serializable document body.
§Returns
Returns a Result containing a serde_json::Value representing the response from OpenSearch or an Error if the request fails.
§Example
use opensearch_client::OpenSearchClient;
#[derive(Serialize)]
struct MyDocument {
title: String,
content: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = OpenSearchClient::new("http://localhost:9200");
let document = MyDocument {
title: "My Title".to_string(),
content: "My Content".to_string(),
};
let response = client
.bulk_index_document("my_index", Some("my_id".to_string()), &document)
.await?;
Ok(())
}
Sourcepub async fn bulk_action(
&self,
action: BulkAction,
body: Option<&Value>,
) -> Result<(), Error>
pub async fn bulk_action( &self, action: BulkAction, body: Option<&Value>, ) -> Result<(), Error>
Sends a bulk action to the OpenSearch server.
§Arguments
command
- A string slice that holds the command to be executed.action
- ABulkAction
enum that specifies the action to be taken.body
- An optionalserde_json::Value
that holds the request body.
§Returns
A Result
containing a serde_json::Value
object representing the
response from the server, or an Error
if the request failed.
§Examples
use opensearch_client::{BulkAction, OpenSearchClient};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = OpenSearchClient::new("http://localhost:9200")?;
let action = BulkAction::Index {
index: "my_index".to_string(),
id: Some("1".to_string()),
};
let response = client.bulk_action("index", action, None).await?;
Ok(())
}
Sourcepub async fn bulk_create_document<T: Serialize>(
&self,
index: &str,
id: &str,
body: &T,
) -> Result<(), Error>
pub async fn bulk_create_document<T: Serialize>( &self, index: &str, id: &str, body: &T, ) -> Result<(), Error>
Sends a bulk create request to the OpenSearch cluster with the specified index, id and body.
§Arguments
index
- A string slice that holds the name of the index.id
- A string slice that holds the id of the document.body
- A generic typeT
that holds the body of the document to be created.
§Returns
Returns a Result
containing a serde_json::Value
on success, or an
Error
on failure.
Sourcepub async fn bulk_update_document(
&self,
index: &str,
id: &str,
body: &UpdateActionBody,
) -> Result<(), Error>
pub async fn bulk_update_document( &self, index: &str, id: &str, body: &UpdateActionBody, ) -> Result<(), Error>
Asynchronously updates a document in bulk.
§Arguments
index
- A string slice that holds the name of the index.id
- A string slice that holds the ID of the document to update.body
- AnUpdateAction
struct that holds the update action to perform.
§Returns
Returns a Result
containing a serde_json::Value
on success, or an
Error
on failure.
Sourcepub async fn flush_bulk(&self) -> Result<BulkResponse, Error>
pub async fn flush_bulk(&self) -> Result<BulkResponse, Error>
Sends a bulk request to the OpenSearch server and returns a
BulkResponse
. If the bulker size is 0, it returns an empty
BulkResponse
. If the bulk request contains errors, it logs the errors
and returns the BulkResponse
.
§Examples
use opensearch_client::OpenSearchClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = OpenSearchClient::new("http://localhost:9200", "user", "password");
let response = client.flush_bulk().await?;
println!("{:?}", response);
Ok(())
}
Sourcepub async fn index_document<T: Serialize>(
&self,
index: &String,
body: &T,
id: Option<String>,
) -> Result<IndexResponse, Error>
pub async fn index_document<T: Serialize>( &self, index: &String, body: &T, id: Option<String>, ) -> Result<IndexResponse, Error>
Indexes a document in the specified index with the given body and optional ID.
§Arguments
index
- A string slice that holds the name of the index to which the document will be added.body
- A reference to a serializable object that represents the document to be added.id
- An optional string slice that holds the ID of the document to be added. If not provided, a new ID will be generated.
§Returns
A Result
containing an IndexResponse
object if the operation was
successful, or an Error
if an error occurred.
§Examples
use opensearch_client::Client;
#[derive(Serialize)]
struct MyDocument {
title: String,
content: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new("http://localhost:9200")?;
let document = MyDocument {
title: "My Title".to_string(),
content: "My Content".to_string(),
};
let response = client.index_document("my_index", &document, None).await?;
println!("Document ID: {}", response._id);
Ok(())
}
Sourcepub async fn create_document<T: Serialize>(
&self,
index: &String,
id: &String,
body: &T,
) -> Result<IndexResponse, Error>
pub async fn create_document<T: Serialize>( &self, index: &String, id: &String, body: &T, ) -> Result<IndexResponse, Error>
Creates a new document in the specified index with the given ID and body.
§Arguments
index
- A string slice that holds the name of the index.id
- A string slice that holds the ID of the document.body
- A generic typeT
that holds the body of the document. The typeT
must implement theSerialize
trait from theserde
crate.
§Returns
Returns a Result
containing an IndexResponse
on success, or an Error
on failure.
§Examples
use opensearch_client::OpenSearchClient;
#[derive(Serialize)]
struct MyDocument {
title: String,
content: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = OpenSearchClient::new("http://localhost:9200")?;
let document = MyDocument {
title: "My Title".to_string(),
content: "My Content".to_string(),
};
let response = client.create_document("my_index", "1", &document).await?;
Ok(())
}
Sourcepub async fn get_typed<T: DeserializeOwned + Default>(
&self,
index: &str,
id: &str,
) -> Result<GetResponseContent<T>, Error>
pub async fn get_typed<T: DeserializeOwned + Default>( &self, index: &str, id: &str, ) -> Result<GetResponseContent<T>, Error>
Asynchronously retrieves a typed document from the specified index and ID.
§Arguments
index
- A string slice that holds the name of the index to retrieve the document from.id
- A string slice that holds the ID of the document to retrieve.
§Returns
A Result
containing the deserialized content of the retrieved document,
or an Error
if the operation failed.
§Generic Type Parameters
T
- The type of the document to retrieve. Must implement theDeserializeOwned
andstd::default::Default
traits.
Sourcepub async fn update_document(
&self,
index: &str,
id: &str,
action: &UpdateAction,
) -> Result<IndexResponse, Error>
pub async fn update_document( &self, index: &str, id: &str, action: &UpdateAction, ) -> Result<IndexResponse, Error>
Updates a document in the specified index with the given ID using the provided update action.
§Arguments
index
- A string slice that holds the name of the index to update the document in.id
- A string slice that holds the ID of the document to update.action
- A reference to anUpdateAction
enum that specifies the update action to perform.
§Returns
Returns a Result
containing an IndexResponse
struct if the update was
successful, or an Error
if an error occurred.
§Example
use opensearch_client::{Client, UpdateAction};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new("http://localhost:9200")?;
let index = "my_index";
let id = "1";
let action = UpdateAction::new().doc(json!({"foo": "bar"}));
let response = client.update_document(index, id, &action).await?;
Ok(())
}
pub fn get_bulker( &self, bulk_size: u32, max_concurrent_connections: u32, ) -> (JoinHandle<()>, Bulker)
pub fn bulker(&self) -> BulkerBuilder
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OsClient
impl !RefUnwindSafe for OsClient
impl Send for OsClient
impl Sync for OsClient
impl Unpin for OsClient
impl !UnwindSafe for OsClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more