Skip to content

Add body field parameters to 'indices.create' API #1688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 70 additions & 46 deletions elasticsearch/_async/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,9 +1010,9 @@ async def get(self, index, id, doc_type=None, params=None, headers=None):
to include in the response.
:arg preference: Specifies the node or shard the operation
should be performed on. Random by default.
:arg realtime: Boolean) If true, the request is real-time as
:arg realtime: Boolean) If true, the request is real-time as
opposed to near-real-time. Default: True
:arg refresh: If true, Elasticsearch refreshes the affected
:arg refresh: If true, Elasticsearch refreshes the affected
shards to make this operation visible to search. If false, do nothing
with refreshes.
:arg routing: Target the specified primary shard.
Expand Down Expand Up @@ -1614,8 +1614,8 @@ async def search(
:arg doc_type: A comma-separated list of document types to
search; leave empty to perform the operation on all types
:arg _source: Indicates which source fields are returned for
matching documents. These fields are returned in the hits._source
property of the search response.
matching documents. These
fields are returned in the hits._source property of the search response.
:arg _source_excludes: A list of fields to exclude from the
returned _source field
:arg _source_includes: A list of fields to extract and return
Expand Down Expand Up @@ -1645,19 +1645,22 @@ async def search(
:arg df: The field to use as default where no field prefix is
given in the query string
:arg docvalue_fields: Array of wildcard (*) patterns. The
request returns doc values for field names matching these patterns in
the hits.fields property of the response.
request returns doc values for field
names matching these patterns in the hits.fields property of the
response.
:arg expand_wildcards: Whether to expand wildcard expression to
concrete indices that are open, closed or both. Valid choices: open,
closed, hidden, none, all Default: open
:arg explain: If true, returns detailed information about score
computation as part of a hit.
:arg fields: Array of wildcard (*) patterns. The request returns
values for field names matching these patterns in the hits.fields
property of the response.
values for field names
matching these patterns in the hits.fields property of the response.
:arg from_: Starting document offset. By default, you cannot
page through more than 10,000 hits using the from and size parameters.
To page through more hits, use the search_after parameter.
page through more than 10,000
hits using the from and size parameters. To page through more hits, use
the
search_after parameter.
:arg highlight:
:arg ignore_throttled: Whether specified concrete, expanded or
aliased indices should be ignored when throttled
Expand All @@ -1675,13 +1678,15 @@ async def search(
that all shards involved in search should have for this request to be
successful
:arg min_score: Minimum _score for matching documents. Documents
with a lower _score are not included in the search results.
with a lower _score are
not included in the search results.
:arg pit: Limits the search to a point in time (PIT). If you
provide a PIT, you cannot specify an <index> in the request path.
provide a PIT, you
cannot specify an <index> in the request path.
:arg post_filter:
:arg pre_filter_shard_size: 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
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
Expand All @@ -1698,8 +1703,8 @@ async def search(
be rendered as an integer or an object in the rest search response
:arg routing: A comma-separated list of specific routing values
:arg runtime_mappings: Defines one or more runtime fields in the
search request. These fields take precedence over mapped fields with the
same name.
search request. These fields take
precedence over mapped fields with the same name.
:arg script_fields: Retrieve a script evaluation (based on
different fields) for each hit.
:arg scroll: Specify how long a consistent view of the index
Expand All @@ -1708,21 +1713,27 @@ async def search(
:arg search_type: Search operation type Valid choices:
query_then_fetch, dfs_query_then_fetch
:arg seq_no_primary_term: If true, returns sequence number and
primary term of the last modification of each hit. See Optimistic
concurrency control.
primary term of the last modification
of each hit. See Optimistic concurrency control.
:arg size: The number of hits to return. By default, you cannot
page through more than 10,000 hits using the from and size parameters.
To page through more hits, use the search_after parameter.
page through more
than 10,000 hits using the from and size parameters. To page through
more
hits, use the search_after parameter.
:arg slice:
:arg sort:
:arg stats: Stats groups to associate with the search. Each
group maintains a statistics aggregation for its associated searches.
You can retrieve these stats using the indices stats API.
group maintains a statistics
aggregation for its associated searches. You can retrieve these stats
using
the indices stats API.
:arg stored_fields: List of stored fields to return as part of a
hit. If no fields are specified, no stored fields are included in the
response. If this field is specified, the _source parameter defaults to
false. You can pass _source: true to return both source fields and
stored fields in the search response.
hit. If no fields are specified,
no stored fields are included in the response. If this field is
specified, the _source
parameter defaults to false. You can pass _source: true to return both
source fields
and stored fields in the search response.
:arg suggest:
:arg suggest_field: Specifies which field to use for
suggestions.
Expand All @@ -1732,18 +1743,24 @@ async def search(
:arg suggest_text: The source text for which the suggestions
should be returned.
:arg terminate_after: Maximum number of documents to collect for
each shard. If a query reaches this limit, Elasticsearch terminates the
query early. Elasticsearch collects documents before sorting. Defaults
to 0, which does not terminate query execution early.
each shard. If a query reaches this
limit, Elasticsearch terminates the query early. Elasticsearch collects
documents
before sorting. Defaults to 0, which does not terminate query execution
early.
:arg timeout: Specifies the period of time to wait for a
response from each shard. If no response is received before the timeout
expires, the request fails and returns an error. Defaults to no timeout.
response from each shard. If no response
is received before the timeout expires, the request fails and returns an
error.
Defaults to no timeout.
:arg track_scores: If true, calculate and return document
scores, even if the scores are not used for sorting.
:arg track_total_hits: Number of hits matching the query to
count accurately. If true, the exact number of hits is returned at the
cost of some performance. If false, the response does not include the
total number of hits matching the query. Defaults to 10,000 hits.
count accurately. If true, the exact
number of hits is returned at the cost of some performance. If false,
the
response does not include the total number of hits matching the query.
Defaults to 10,000 hits.
:arg typed_keys: Specify whether aggregation and suggester names
should be prefixed by their respective types in the response
:arg version: If true, returns document version as part of a
Expand Down Expand Up @@ -1945,6 +1962,7 @@ async def termvectors(
"scripted_upsert",
"upsert",
],
body_required=True,
)
async def update(self, index, id, body, doc_type=None, params=None, headers=None):
"""
Expand All @@ -1958,13 +1976,15 @@ async def update(self, index, id, body, doc_type=None, params=None, headers=None
partial `doc`
:arg doc_type: The type of the document
:arg _source: Set to false to disable source retrieval. You can
also specify a comma-separated list of the fields you want to retrieve.
also specify a comma-separated
list of the fields you want to retrieve.
:arg _source_excludes: Specify the source fields you want to
exclude.
:arg _source_includes: Specify the source fields you want to
retrieve.
:arg detect_noop: Set to false to disable setting 'result' in
the response to 'noop' if no change to the document occurred.
the response
to 'noop' if no change to the document occurred.
:arg doc: A partial update to an existing document.
:arg doc_as_upsert: Set to true to use the contents of 'doc' as
the value of 'upsert'
Expand All @@ -1974,10 +1994,11 @@ async def update(self, index, id, body, doc_type=None, params=None, headers=None
this sequence number.
:arg lang: The script language. Default: painless
:arg refresh: If 'true', Elasticsearch refreshes 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' do
nothing with refreshes. Valid choices: true, false, wait_for Default:
false
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' do nothing with refreshes. Valid choices:
true, false, wait_for Default: false
:arg require_alias: If true, the destination must be an index
alias.
:arg retry_on_conflict: Specify how many times should the
Expand All @@ -1988,15 +2009,18 @@ async def update(self, index, id, body, doc_type=None, params=None, headers=None
:arg scripted_upsert: Set to true to execute the script whether
or not the document exists.
:arg timeout: Period to wait for dynamic mapping updates and
active shards. This guarantees Elasticsearch waits for at least the
timeout before failing. The actual wait time could be longer,
particularly when multiple waits occur. Default: 1m
active shards.
This guarantees Elasticsearch waits for at least the timeout before
failing.
The actual wait time could be longer, particularly when multiple waits
occur. Default: 1m
:arg upsert: If the document does not already exist, the
contents of 'upsert' are inserted as a new document. If the document
exists, the 'script' is executed.
contents of 'upsert' are inserted as a
new document. If the document exists, the 'script' is executed.
:arg wait_for_active_shards: The number of shard copies that
must be active before proceeding with the operations. Set to 'all' or
any positive integer up to the total number of shards in the index
must be active before proceeding with the operations.
Set to 'all' or any positive integer up to the total number of shards in
the index
(number_of_replicas+1). Defaults to 1 meaning the primary shard.
Default: 1
"""
Expand Down
2 changes: 1 addition & 1 deletion elasticsearch/_async/client/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class AsyncElasticsearch(object):
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
params: Optional[MutableMapping[str, Any]] = ...,
headers: Optional[MutableMapping[str, str]] = ...,
) -> Any: ...
) -> bool: ...
async def exists_source(
self,
*,
Expand Down
60 changes: 39 additions & 21 deletions elasticsearch/_async/client/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ async def flush(self, index=None, params=None, headers=None):
)

@query_params(
"include_type_name", "master_timeout", "timeout", "wait_for_active_shards"
"include_type_name",
"master_timeout",
"timeout",
"wait_for_active_shards",
body_params=["aliases", "mappings", "settings"],
)
async def create(self, index, body=None, params=None, headers=None):
"""
Expand All @@ -110,9 +114,16 @@ async def create(self, index, body=None, params=None, headers=None):
:arg index: The name of the index
:arg body: The configuration for the index (`settings` and
`mappings`)
:arg aliases:
:arg include_type_name: Whether a type should be expected in the
body of the mappings.
:arg mappings: Mapping for fields in the index. If specified,
this mapping can include:
- Field names
- Field data types
- Mapping parameters
:arg master_timeout: Specify timeout for connection to master
:arg settings:
:arg timeout: Explicit operation timeout
:arg wait_for_active_shards: Set the number of active shards to
wait for before the operation returns.
Expand Down Expand Up @@ -168,23 +179,29 @@ async def get(self, index, params=None, headers=None):

`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/indices-get-index.html>`_

:arg index: A comma-separated list of index names
:arg index: Comma-separated list of data streams, indices, and
index aliases used to limit the request. Wildcard expressions (*) are
supported.
:arg allow_no_indices: Ignore if a wildcard expression resolves
to no concrete indices (default: false)
:arg expand_wildcards: Whether wildcard expressions should get
expanded to open or closed indices (default: open) Valid choices: open,
closed, hidden, none, all Default: open
:arg flat_settings: Return settings in flat format (default:
false)
:arg ignore_unavailable: Ignore unavailable indexes (default:
false)
:arg include_defaults: Whether to return all default setting for
each of the indices.
:arg include_type_name: Whether to add the type name to the
response (default: false)
:arg local: Return local information, do not retrieve the state
from master node (default: false)
:arg master_timeout: Specify timeout for connection to master
to no concrete indices (default: false) Default: True
:arg expand_wildcards: Type of index that wildcard expressions
can match. If the request can target data streams, this argument
determines whether wildcard expressions match hidden data streams.
Supports comma-separated values, such as open,hidden. Valid choices:
open, closed, hidden, none, all Default: open
:arg flat_settings: If true, returns settings in flat format.
:arg ignore_unavailable: If false, requests that target a
missing index return an error.
:arg include_defaults: If true, return all default settings in
the response.
:arg include_type_name: If true, a mapping type is expected in
the body of mappings.
:arg local: If true, the request retrieves information from the
local node only. Defaults to false, which means information is retrieved
from the master node.
:arg master_timeout: Period to wait for a connection to the
master node. If no response is received before the timeout expires, the
request fails and returns an error. Default: 30s
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
Expand Down Expand Up @@ -616,7 +633,10 @@ async def delete_alias(self, index, name, params=None, headers=None):
raise ValueError("Empty value passed for a required argument.")

return await self.transport.perform_request(
"DELETE", _make_path(index, "_alias", name), params=params, headers=headers
"DELETE",
_make_path(index, "_aliases", name),
params=params,
headers=headers,
)

@query_params("create", "include_type_name", "master_timeout", "order")
Expand Down Expand Up @@ -814,9 +834,7 @@ async def stats(self, index=None, metric=None, params=None, headers=None):
:arg index: A comma-separated list of index names; use `_all` or
empty string to perform the operation on all indices
:arg metric: Limit the information returned the specific
metrics. Valid choices: _all, completion, docs, fielddata, query_cache,
flush, get, indexing, merge, request_cache, refresh, search, segments,
store, warmer, suggest
metrics.
:arg completion_fields: A comma-separated list of fields for
`fielddata` and `suggest` index metric (supports wildcards)
:arg expand_wildcards: Whether to expand wildcard expression to
Expand Down
Loading