Skip to content

Commit 4648592

Browse files
committed
Add more body fields to indices APIs
1 parent 642d33f commit 4648592

File tree

18 files changed

+690
-292
lines changed

18 files changed

+690
-292
lines changed

elasticsearch/_async/client/__init__.py

Lines changed: 70 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,9 +1010,9 @@ async def get(self, index, id, doc_type=None, params=None, headers=None):
10101010
to include in the response.
10111011
:arg preference: Specifies the node or shard the operation
10121012
should be performed on. Random by default.
1013-
:arg realtime: Boolean) If true, the request is real-time as
1013+
:arg realtime: Boolean) If true, the request is real-time as
10141014
opposed to near-real-time. Default: True
1015-
:arg refresh: If true, Elasticsearch refreshes the affected
1015+
:arg refresh: If true, Elasticsearch refreshes the affected
10161016
shards to make this operation visible to search. If false, do nothing
10171017
with refreshes.
10181018
:arg routing: Target the specified primary shard.
@@ -1614,8 +1614,8 @@ async def search(
16141614
:arg doc_type: A comma-separated list of document types to
16151615
search; leave empty to perform the operation on all types
16161616
:arg _source: Indicates which source fields are returned for
1617-
matching documents. These fields are returned in the hits._source
1618-
property of the search response.
1617+
matching documents. These
1618+
fields are returned in the hits._source property of the search response.
16191619
:arg _source_excludes: A list of fields to exclude from the
16201620
returned _source field
16211621
:arg _source_includes: A list of fields to extract and return
@@ -1645,19 +1645,22 @@ async def search(
16451645
:arg df: The field to use as default where no field prefix is
16461646
given in the query string
16471647
:arg docvalue_fields: Array of wildcard (*) patterns. The
1648-
request returns doc values for field names matching these patterns in
1649-
the hits.fields property of the response.
1648+
request returns doc values for field
1649+
names matching these patterns in the hits.fields property of the
1650+
response.
16501651
:arg expand_wildcards: Whether to expand wildcard expression to
16511652
concrete indices that are open, closed or both. Valid choices: open,
16521653
closed, hidden, none, all Default: open
16531654
:arg explain: If true, returns detailed information about score
16541655
computation as part of a hit.
16551656
:arg fields: Array of wildcard (*) patterns. The request returns
1656-
values for field names matching these patterns in the hits.fields
1657-
property of the response.
1657+
values for field names
1658+
matching these patterns in the hits.fields property of the response.
16581659
:arg from_: Starting document offset. By default, you cannot
1659-
page through more than 10,000 hits using the from and size parameters.
1660-
To page through more hits, use the search_after parameter.
1660+
page through more than 10,000
1661+
hits using the from and size parameters. To page through more hits, use
1662+
the
1663+
search_after parameter.
16611664
:arg highlight:
16621665
:arg ignore_throttled: Whether specified concrete, expanded or
16631666
aliased indices should be ignored when throttled
@@ -1675,13 +1678,15 @@ async def search(
16751678
that all shards involved in search should have for this request to be
16761679
successful
16771680
:arg min_score: Minimum _score for matching documents. Documents
1678-
with a lower _score are not included in the search results.
1681+
with a lower _score are
1682+
not included in the search results.
16791683
:arg pit: Limits the search to a point in time (PIT). If you
1680-
provide a PIT, you cannot specify an <index> in the request path.
1684+
provide a PIT, you
1685+
cannot specify an <index> in the request path.
16811686
:arg post_filter:
16821687
:arg pre_filter_shard_size: A threshold that enforces a pre-
16831688
filter roundtrip to prefilter search shards based on query rewriting if
1684-
the number of shards the search request expands to exceeds the
1689+
the number of shards the search request expands to exceeds the
16851690
threshold. This filter roundtrip can limit the number of shards
16861691
significantly if for instance a shard can not match any documents based
16871692
on its rewrite method ie. if date filters are mandatory to match but the
@@ -1698,8 +1703,8 @@ async def search(
16981703
be rendered as an integer or an object in the rest search response
16991704
:arg routing: A comma-separated list of specific routing values
17001705
:arg runtime_mappings: Defines one or more runtime fields in the
1701-
search request. These fields take precedence over mapped fields with the
1702-
same name.
1706+
search request. These fields take
1707+
precedence over mapped fields with the same name.
17031708
:arg script_fields: Retrieve a script evaluation (based on
17041709
different fields) for each hit.
17051710
:arg scroll: Specify how long a consistent view of the index
@@ -1708,21 +1713,27 @@ async def search(
17081713
:arg search_type: Search operation type Valid choices:
17091714
query_then_fetch, dfs_query_then_fetch
17101715
:arg seq_no_primary_term: If true, returns sequence number and
1711-
primary term of the last modification of each hit. See Optimistic
1712-
concurrency control.
1716+
primary term of the last modification
1717+
of each hit. See Optimistic concurrency control.
17131718
:arg size: The number of hits to return. By default, you cannot
1714-
page through more than 10,000 hits using the from and size parameters.
1715-
To page through more hits, use the search_after parameter.
1719+
page through more
1720+
than 10,000 hits using the from and size parameters. To page through
1721+
more
1722+
hits, use the search_after parameter.
17161723
:arg slice:
17171724
:arg sort:
17181725
:arg stats: Stats groups to associate with the search. Each
1719-
group maintains a statistics aggregation for its associated searches.
1720-
You can retrieve these stats using the indices stats API.
1726+
group maintains a statistics
1727+
aggregation for its associated searches. You can retrieve these stats
1728+
using
1729+
the indices stats API.
17211730
:arg stored_fields: List of stored fields to return as part of a
1722-
hit. If no fields are specified, no stored fields are included in the
1723-
response. If this field is specified, the _source parameter defaults to
1724-
false. You can pass _source: true to return both source fields and
1725-
stored fields in the search response.
1731+
hit. If no fields are specified,
1732+
no stored fields are included in the response. If this field is
1733+
specified, the _source
1734+
parameter defaults to false. You can pass _source: true to return both
1735+
source fields
1736+
and stored fields in the search response.
17261737
:arg suggest:
17271738
:arg suggest_field: Specifies which field to use for
17281739
suggestions.
@@ -1732,18 +1743,24 @@ async def search(
17321743
:arg suggest_text: The source text for which the suggestions
17331744
should be returned.
17341745
:arg terminate_after: Maximum number of documents to collect for
1735-
each shard. If a query reaches this limit, Elasticsearch terminates the
1736-
query early. Elasticsearch collects documents before sorting. Defaults
1737-
to 0, which does not terminate query execution early.
1746+
each shard. If a query reaches this
1747+
limit, Elasticsearch terminates the query early. Elasticsearch collects
1748+
documents
1749+
before sorting. Defaults to 0, which does not terminate query execution
1750+
early.
17381751
:arg timeout: Specifies the period of time to wait for a
1739-
response from each shard. If no response is received before the timeout
1740-
expires, the request fails and returns an error. Defaults to no timeout.
1752+
response from each shard. If no response
1753+
is received before the timeout expires, the request fails and returns an
1754+
error.
1755+
Defaults to no timeout.
17411756
:arg track_scores: If true, calculate and return document
17421757
scores, even if the scores are not used for sorting.
17431758
:arg track_total_hits: Number of hits matching the query to
1744-
count accurately. If true, the exact number of hits is returned at the
1745-
cost of some performance. If false, the response does not include the
1746-
total number of hits matching the query. Defaults to 10,000 hits.
1759+
count accurately. If true, the exact
1760+
number of hits is returned at the cost of some performance. If false,
1761+
the
1762+
response does not include the total number of hits matching the query.
1763+
Defaults to 10,000 hits.
17471764
:arg typed_keys: Specify whether aggregation and suggester names
17481765
should be prefixed by their respective types in the response
17491766
:arg version: If true, returns document version as part of a
@@ -1945,6 +1962,7 @@ async def termvectors(
19451962
"scripted_upsert",
19461963
"upsert",
19471964
],
1965+
body_required=True,
19481966
)
19491967
async def update(self, index, id, body, doc_type=None, params=None, headers=None):
19501968
"""
@@ -1958,13 +1976,15 @@ async def update(self, index, id, body, doc_type=None, params=None, headers=None
19581976
partial `doc`
19591977
:arg doc_type: The type of the document
19601978
:arg _source: Set to false to disable source retrieval. You can
1961-
also specify a comma-separated list of the fields you want to retrieve.
1979+
also specify a comma-separated
1980+
list of the fields you want to retrieve.
19621981
:arg _source_excludes: Specify the source fields you want to
19631982
exclude.
19641983
:arg _source_includes: Specify the source fields you want to
19651984
retrieve.
19661985
:arg detect_noop: Set to false to disable setting 'result' in
1967-
the response to 'noop' if no change to the document occurred.
1986+
the response
1987+
to 'noop' if no change to the document occurred.
19681988
:arg doc: A partial update to an existing document.
19691989
:arg doc_as_upsert: Set to true to use the contents of 'doc' as
19701990
the value of 'upsert'
@@ -1974,10 +1994,11 @@ async def update(self, index, id, body, doc_type=None, params=None, headers=None
19741994
this sequence number.
19751995
:arg lang: The script language. Default: painless
19761996
:arg refresh: If 'true', Elasticsearch refreshes the affected
1977-
shards to make this operation visible to search, if 'wait_for' then wait
1978-
for a refresh to make this operation visible to search, if 'false' do
1979-
nothing with refreshes. Valid choices: true, false, wait_for Default:
1980-
false
1997+
shards to make this operation
1998+
visible to search, if 'wait_for' then wait for a refresh to make this
1999+
operation
2000+
visible to search, if 'false' do nothing with refreshes. Valid choices:
2001+
true, false, wait_for Default: false
19812002
:arg require_alias: If true, the destination must be an index
19822003
alias.
19832004
:arg retry_on_conflict: Specify how many times should the
@@ -1988,15 +2009,18 @@ async def update(self, index, id, body, doc_type=None, params=None, headers=None
19882009
:arg scripted_upsert: Set to true to execute the script whether
19892010
or not the document exists.
19902011
:arg timeout: Period to wait for dynamic mapping updates and
1991-
active shards. This guarantees Elasticsearch waits for at least the
1992-
timeout before failing. The actual wait time could be longer,
1993-
particularly when multiple waits occur. Default: 1m
2012+
active shards.
2013+
This guarantees Elasticsearch waits for at least the timeout before
2014+
failing.
2015+
The actual wait time could be longer, particularly when multiple waits
2016+
occur. Default: 1m
19942017
:arg upsert: If the document does not already exist, the
1995-
contents of 'upsert' are inserted as a new document. If the document
1996-
exists, the 'script' is executed.
2018+
contents of 'upsert' are inserted as a
2019+
new document. If the document exists, the 'script' is executed.
19972020
:arg wait_for_active_shards: The number of shard copies that
1998-
must be active before proceeding with the operations. Set to 'all' or
1999-
any positive integer up to the total number of shards in the index
2021+
must be active before proceeding with the operations.
2022+
Set to 'all' or any positive integer up to the total number of shards in
2023+
the index
20002024
(number_of_replicas+1). Defaults to 1 meaning the primary shard.
20012025
Default: 1
20022026
"""

elasticsearch/_async/client/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ class AsyncElasticsearch(object):
440440
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
441441
params: Optional[MutableMapping[str, Any]] = ...,
442442
headers: Optional[MutableMapping[str, str]] = ...,
443-
) -> Any: ...
443+
) -> bool: ...
444444
async def exists_source(
445445
self,
446446
*,

elasticsearch/_async/client/indices.py

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ async def flush(self, index=None, params=None, headers=None):
9999
)
100100

101101
@query_params(
102-
"include_type_name", "master_timeout", "timeout", "wait_for_active_shards"
102+
"include_type_name",
103+
"master_timeout",
104+
"timeout",
105+
"wait_for_active_shards",
106+
body_params=["aliases", "mappings", "settings"],
103107
)
104108
async def create(self, index, body=None, params=None, headers=None):
105109
"""
@@ -110,9 +114,16 @@ async def create(self, index, body=None, params=None, headers=None):
110114
:arg index: The name of the index
111115
:arg body: The configuration for the index (`settings` and
112116
`mappings`)
117+
:arg aliases:
113118
:arg include_type_name: Whether a type should be expected in the
114119
body of the mappings.
120+
:arg mappings: Mapping for fields in the index. If specified,
121+
this mapping can include:
122+
- Field names
123+
- Field data types
124+
- Mapping parameters
115125
:arg master_timeout: Specify timeout for connection to master
126+
:arg settings:
116127
:arg timeout: Explicit operation timeout
117128
:arg wait_for_active_shards: Set the number of active shards to
118129
wait for before the operation returns.
@@ -168,23 +179,29 @@ async def get(self, index, params=None, headers=None):
168179
169180
`<https://www.elastic.co/guide/en/elasticsearch/reference/7.x/indices-get-index.html>`_
170181
171-
:arg index: A comma-separated list of index names
182+
:arg index: Comma-separated list of data streams, indices, and
183+
index aliases used to limit the request. Wildcard expressions (*) are
184+
supported.
172185
:arg allow_no_indices: Ignore if a wildcard expression resolves
173-
to no concrete indices (default: false)
174-
:arg expand_wildcards: Whether wildcard expressions should get
175-
expanded to open or closed indices (default: open) Valid choices: open,
176-
closed, hidden, none, all Default: open
177-
:arg flat_settings: Return settings in flat format (default:
178-
false)
179-
:arg ignore_unavailable: Ignore unavailable indexes (default:
180-
false)
181-
:arg include_defaults: Whether to return all default setting for
182-
each of the indices.
183-
:arg include_type_name: Whether to add the type name to the
184-
response (default: false)
185-
:arg local: Return local information, do not retrieve the state
186-
from master node (default: false)
187-
:arg master_timeout: Specify timeout for connection to master
186+
to no concrete indices (default: false) Default: True
187+
:arg expand_wildcards: Type of index that wildcard expressions
188+
can match. If the request can target data streams, this argument
189+
determines whether wildcard expressions match hidden data streams.
190+
Supports comma-separated values, such as open,hidden. Valid choices:
191+
open, closed, hidden, none, all Default: open
192+
:arg flat_settings: If true, returns settings in flat format.
193+
:arg ignore_unavailable: If false, requests that target a
194+
missing index return an error.
195+
:arg include_defaults: If true, return all default settings in
196+
the response.
197+
:arg include_type_name: If true, a mapping type is expected in
198+
the body of mappings.
199+
:arg local: If true, the request retrieves information from the
200+
local node only. Defaults to false, which means information is retrieved
201+
from the master node.
202+
:arg master_timeout: Period to wait for a connection to the
203+
master node. If no response is received before the timeout expires, the
204+
request fails and returns an error. Default: 30s
188205
"""
189206
if index in SKIP_IN_PATH:
190207
raise ValueError("Empty value passed for a required argument 'index'.")
@@ -616,7 +633,10 @@ async def delete_alias(self, index, name, params=None, headers=None):
616633
raise ValueError("Empty value passed for a required argument.")
617634

618635
return await self.transport.perform_request(
619-
"DELETE", _make_path(index, "_alias", name), params=params, headers=headers
636+
"DELETE",
637+
_make_path(index, "_aliases", name),
638+
params=params,
639+
headers=headers,
620640
)
621641

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

0 commit comments

Comments
 (0)