Skip to content

Commit 7d3059a

Browse files
committed
Add body fields to scroll and search_mvt
1 parent 2cd20f8 commit 7d3059a

File tree

7 files changed

+231
-76
lines changed

7 files changed

+231
-76
lines changed

elasticsearch/_async/client/__init__.py

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ async def bulk(self, body, index=None, doc_type=None, params=None, headers=None)
469469
body=body,
470470
)
471471

472-
@query_params()
472+
@query_params(body_params=["scroll_id"])
473473
async def clear_scroll(self, body=None, scroll_id=None, params=None, headers=None):
474474
"""
475475
Explicitly clears the search context for a scroll.
@@ -1496,7 +1496,13 @@ async def scripts_painless_execute(self, body=None, params=None, headers=None):
14961496
body=body,
14971497
)
14981498

1499-
@query_params("rest_total_hits_as_int", "scroll")
1499+
@query_params(
1500+
"rest_total_hits_as_int",
1501+
"scroll",
1502+
"scroll_id",
1503+
"total_hits_as_integer",
1504+
body_params=["rest_total_hits_as_int", "scroll", "scroll_id"],
1505+
)
15001506
async def scroll(self, body=None, scroll_id=None, params=None, headers=None):
15011507
"""
15021508
Allows to retrieve a large numbers of results from a single search request.
@@ -1506,10 +1512,11 @@ async def scroll(self, body=None, scroll_id=None, params=None, headers=None):
15061512
:arg body: The scroll ID if not passed by URL or query
15071513
parameter.
15081514
:arg scroll_id: The scroll ID
1509-
:arg rest_total_hits_as_int: Indicates whether hits.total should
1510-
be rendered as an integer or an object in the rest search response
1511-
:arg scroll: Specify how long a consistent view of the index
1512-
should be maintained for scrolled search
1515+
:arg rest_total_hits_as_int: If true, the API response’s
1516+
hit.total property is returned as an integer. If false, the API
1517+
response’s hit.total property is returned as an object.
1518+
:arg scroll: Period to retain the search context for scrolling.
1519+
:arg total_hits_as_integer:
15131520
"""
15141521
if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH:
15151522
raise ValueError("You need to supply scroll_id or body.")
@@ -2297,7 +2304,25 @@ async def terms_enum(self, index, body=None, params=None, headers=None):
22972304
body=body,
22982305
)
22992306

2300-
@query_params("exact_bounds", "extent", "grid_precision", "grid_type", "size")
2307+
@query_params(
2308+
"exact_bounds",
2309+
"extent",
2310+
"grid_precision",
2311+
"grid_type",
2312+
"size",
2313+
body_params=[
2314+
"aggs",
2315+
"exact_bounds",
2316+
"extent",
2317+
"fields",
2318+
"grid_precision",
2319+
"grid_type",
2320+
"query",
2321+
"runtime_mappings",
2322+
"size",
2323+
"sort",
2324+
],
2325+
)
23012326
async def search_mvt(
23022327
self, index, field, zoom, x, y, body=None, params=None, headers=None
23032328
):
@@ -2319,17 +2344,52 @@ async def search_mvt(
23192344
:arg x: X coordinate for the vector tile to search
23202345
:arg y: Y coordinate for the vector tile to search
23212346
:arg body: Search request body.
2322-
:arg exact_bounds: If false, the meta layer's feature is the
2323-
bounding box of the tile. If true, the meta layer's feature is a
2324-
bounding box resulting from a `geo_bounds` aggregation.
2325-
:arg extent: Size, in pixels, of a side of the vector tile.
2326-
Default: 4096
2347+
:arg aggs: Sub-aggregations for the geotile_grid.
2348+
2349+
Supports the following aggregation types:
2350+
- avg
2351+
- cardinality
2352+
- max
2353+
- min
2354+
- sum
2355+
:arg exact_bounds: If false, the meta layer’s feature is the
2356+
bounding box of the tile.
2357+
If true, the meta layer’s feature is a bounding box resulting from a
2358+
geo_bounds aggregation. The aggregation runs on <field> values that
2359+
intersect
2360+
the <zoom>/<x>/<y> tile with wrap_longitude set to false. The resulting
2361+
bounding box may be larger than the vector tile.
2362+
:arg extent: Size, in pixels, of a side of the tile. Vector
2363+
tiles are square with equal sides.
2364+
:arg fields: Fields to return in the `hits` layer. Supports
2365+
wildcards (`*`).
2366+
This parameter does not support fields with array values. Fields with
2367+
array
2368+
values may return inconsistent results.
23272369
:arg grid_precision: Additional zoom levels available through
2328-
the aggs layer. Accepts 0-8. Default: 8
2370+
the aggs layer. For example, if <zoom> is 7
2371+
and grid_precision is 8, you can zoom in up to level 15. Accepts 0-8. If
2372+
0, results
2373+
don’t include the aggs layer.
23292374
:arg grid_type: Determines the geometry type for features in the
2330-
aggs layer. Valid choices: grid, point Default: grid
2375+
aggs layer. In the aggs layer,
2376+
each feature represents a geotile_grid cell. If 'grid' each feature is a
2377+
Polygon
2378+
of the cells bounding box. If 'point' each feature is a Point that is
2379+
the centroid
2380+
of the cell.
2381+
:arg query: Query DSL used to filter documents for the search.
2382+
:arg runtime_mappings: Defines one or more runtime fields in the
2383+
search request. These fields take
2384+
precedence over mapped fields with the same name.
23312385
:arg size: Maximum number of features to return in the hits
2332-
layer. Accepts 0-10000. Default: 10000
2386+
layer. Accepts 0-10000.
2387+
If 0, results don’t include the hits layer.
2388+
:arg sort: Sorts features in the hits layer. By default, the API
2389+
calculates a bounding
2390+
box for each feature. It sorts features based on this box’s diagonal
2391+
length,
2392+
from longest to shortest.
23332393
"""
23342394
for param in (index, field, zoom, x, y):
23352395
if param in SKIP_IN_PATH:

elasticsearch/_async/client/__init__.pyi

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ class AsyncElasticsearch(object):
244244
async def clear_scroll(
245245
self,
246246
*,
247-
body: Optional[Union[Mapping[str, Any], str]] = ...,
248-
scroll_id: Optional[Any] = ...,
247+
body: Optional[Mapping[str, Any]] = ...,
248+
scroll_id: Optional[Union[List[str], str]] = ...,
249249
pretty: Optional[bool] = ...,
250250
human: Optional[bool] = ...,
251251
error_trace: Optional[bool] = ...,
@@ -834,9 +834,10 @@ class AsyncElasticsearch(object):
834834
self,
835835
*,
836836
body: Optional[Mapping[str, Any]] = ...,
837-
scroll_id: Optional[Any] = ...,
838837
rest_total_hits_as_int: Optional[bool] = ...,
839-
scroll: Optional[Any] = ...,
838+
scroll: Optional[Union[int, str]] = ...,
839+
scroll_id: Optional[str] = ...,
840+
total_hits_as_integer: Optional[bool] = ...,
840841
pretty: Optional[bool] = ...,
841842
human: Optional[bool] = ...,
842843
error_trace: Optional[bool] = ...,
@@ -1229,17 +1230,35 @@ class AsyncElasticsearch(object):
12291230
async def search_mvt(
12301231
self,
12311232
*,
1232-
index: Any,
1233-
field: Any,
1234-
zoom: Any,
1235-
x: Any,
1236-
y: Any,
1233+
index: Union[List[str], str],
1234+
field: str,
1235+
zoom: int,
1236+
x: int,
1237+
y: int,
12371238
body: Optional[Mapping[str, Any]] = ...,
1239+
aggs: Optional[Mapping[str, Mapping[str, Any]]] = ...,
12381240
exact_bounds: Optional[bool] = ...,
1239-
extent: Optional[Any] = ...,
1240-
grid_precision: Optional[Any] = ...,
1241-
grid_type: Optional[Any] = ...,
1242-
size: Optional[Any] = ...,
1241+
extent: Optional[int] = ...,
1242+
fields: Optional[Union[List[str], str]] = ...,
1243+
grid_precision: Optional[int] = ...,
1244+
grid_type: Optional[Union[Literal["grid", "point"], str]] = ...,
1245+
query: Optional[Mapping[str, Any]] = ...,
1246+
runtime_mappings: Optional[Mapping[str, Mapping[str, Any]]] = ...,
1247+
size: Optional[int] = ...,
1248+
sort: Optional[
1249+
Union[
1250+
List[
1251+
Union[
1252+
Mapping[str, Any],
1253+
Union[Literal["asc", "desc", "_doc"], str],
1254+
str,
1255+
]
1256+
],
1257+
Union[
1258+
Mapping[str, Any], Union[Literal["asc", "desc", "_doc"], str], str
1259+
],
1260+
]
1261+
] = ...,
12431262
pretty: Optional[bool] = ...,
12441263
human: Optional[bool] = ...,
12451264
error_trace: Optional[bool] = ...,
@@ -1252,4 +1271,4 @@ class AsyncElasticsearch(object):
12521271
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
12531272
params: Optional[MutableMapping[str, Any]] = ...,
12541273
headers: Optional[MutableMapping[str, str]] = ...,
1255-
) -> Union[Dict[str, Any], bytes]: ...
1274+
) -> bytes: ...

elasticsearch/client/__init__.py

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def bulk(self, body, index=None, doc_type=None, params=None, headers=None):
467467
body=body,
468468
)
469469

470-
@query_params()
470+
@query_params(body_params=["scroll_id"])
471471
def clear_scroll(self, body=None, scroll_id=None, params=None, headers=None):
472472
"""
473473
Explicitly clears the search context for a scroll.
@@ -1486,7 +1486,13 @@ def scripts_painless_execute(self, body=None, params=None, headers=None):
14861486
body=body,
14871487
)
14881488

1489-
@query_params("rest_total_hits_as_int", "scroll")
1489+
@query_params(
1490+
"rest_total_hits_as_int",
1491+
"scroll",
1492+
"scroll_id",
1493+
"total_hits_as_integer",
1494+
body_params=["rest_total_hits_as_int", "scroll", "scroll_id"],
1495+
)
14901496
def scroll(self, body=None, scroll_id=None, params=None, headers=None):
14911497
"""
14921498
Allows to retrieve a large numbers of results from a single search request.
@@ -1496,10 +1502,11 @@ def scroll(self, body=None, scroll_id=None, params=None, headers=None):
14961502
:arg body: The scroll ID if not passed by URL or query
14971503
parameter.
14981504
:arg scroll_id: The scroll ID
1499-
:arg rest_total_hits_as_int: Indicates whether hits.total should
1500-
be rendered as an integer or an object in the rest search response
1501-
:arg scroll: Specify how long a consistent view of the index
1502-
should be maintained for scrolled search
1505+
:arg rest_total_hits_as_int: If true, the API response’s
1506+
hit.total property is returned as an integer. If false, the API
1507+
response’s hit.total property is returned as an object.
1508+
:arg scroll: Period to retain the search context for scrolling.
1509+
:arg total_hits_as_integer:
15031510
"""
15041511
if scroll_id in SKIP_IN_PATH and body in SKIP_IN_PATH:
15051512
raise ValueError("You need to supply scroll_id or body.")
@@ -2285,7 +2292,25 @@ def terms_enum(self, index, body=None, params=None, headers=None):
22852292
body=body,
22862293
)
22872294

2288-
@query_params("exact_bounds", "extent", "grid_precision", "grid_type", "size")
2295+
@query_params(
2296+
"exact_bounds",
2297+
"extent",
2298+
"grid_precision",
2299+
"grid_type",
2300+
"size",
2301+
body_params=[
2302+
"aggs",
2303+
"exact_bounds",
2304+
"extent",
2305+
"fields",
2306+
"grid_precision",
2307+
"grid_type",
2308+
"query",
2309+
"runtime_mappings",
2310+
"size",
2311+
"sort",
2312+
],
2313+
)
22892314
def search_mvt(
22902315
self, index, field, zoom, x, y, body=None, params=None, headers=None
22912316
):
@@ -2307,17 +2332,52 @@ def search_mvt(
23072332
:arg x: X coordinate for the vector tile to search
23082333
:arg y: Y coordinate for the vector tile to search
23092334
:arg body: Search request body.
2310-
:arg exact_bounds: If false, the meta layer's feature is the
2311-
bounding box of the tile. If true, the meta layer's feature is a
2312-
bounding box resulting from a `geo_bounds` aggregation.
2313-
:arg extent: Size, in pixels, of a side of the vector tile.
2314-
Default: 4096
2335+
:arg aggs: Sub-aggregations for the geotile_grid.
2336+
2337+
Supports the following aggregation types:
2338+
- avg
2339+
- cardinality
2340+
- max
2341+
- min
2342+
- sum
2343+
:arg exact_bounds: If false, the meta layer’s feature is the
2344+
bounding box of the tile.
2345+
If true, the meta layer’s feature is a bounding box resulting from a
2346+
geo_bounds aggregation. The aggregation runs on <field> values that
2347+
intersect
2348+
the <zoom>/<x>/<y> tile with wrap_longitude set to false. The resulting
2349+
bounding box may be larger than the vector tile.
2350+
:arg extent: Size, in pixels, of a side of the tile. Vector
2351+
tiles are square with equal sides.
2352+
:arg fields: Fields to return in the `hits` layer. Supports
2353+
wildcards (`*`).
2354+
This parameter does not support fields with array values. Fields with
2355+
array
2356+
values may return inconsistent results.
23152357
:arg grid_precision: Additional zoom levels available through
2316-
the aggs layer. Accepts 0-8. Default: 8
2358+
the aggs layer. For example, if <zoom> is 7
2359+
and grid_precision is 8, you can zoom in up to level 15. Accepts 0-8. If
2360+
0, results
2361+
don’t include the aggs layer.
23172362
:arg grid_type: Determines the geometry type for features in the
2318-
aggs layer. Valid choices: grid, point Default: grid
2363+
aggs layer. In the aggs layer,
2364+
each feature represents a geotile_grid cell. If 'grid' each feature is a
2365+
Polygon
2366+
of the cells bounding box. If 'point' each feature is a Point that is
2367+
the centroid
2368+
of the cell.
2369+
:arg query: Query DSL used to filter documents for the search.
2370+
:arg runtime_mappings: Defines one or more runtime fields in the
2371+
search request. These fields take
2372+
precedence over mapped fields with the same name.
23192373
:arg size: Maximum number of features to return in the hits
2320-
layer. Accepts 0-10000. Default: 10000
2374+
layer. Accepts 0-10000.
2375+
If 0, results don’t include the hits layer.
2376+
:arg sort: Sorts features in the hits layer. By default, the API
2377+
calculates a bounding
2378+
box for each feature. It sorts features based on this box’s diagonal
2379+
length,
2380+
from longest to shortest.
23212381
"""
23222382
for param in (index, field, zoom, x, y):
23232383
if param in SKIP_IN_PATH:

0 commit comments

Comments
 (0)