@@ -155,7 +155,41 @@ async def status(
155
155
)
156
156
157
157
@_rewrite_parameters (
158
- body_fields = True ,
158
+ body_fields = (
159
+ "aggregations" ,
160
+ "aggs" ,
161
+ "collapse" ,
162
+ "docvalue_fields" ,
163
+ "explain" ,
164
+ "ext" ,
165
+ "fields" ,
166
+ "from_" ,
167
+ "highlight" ,
168
+ "indices_boost" ,
169
+ "knn" ,
170
+ "min_score" ,
171
+ "pit" ,
172
+ "post_filter" ,
173
+ "profile" ,
174
+ "query" ,
175
+ "rescore" ,
176
+ "runtime_mappings" ,
177
+ "script_fields" ,
178
+ "search_after" ,
179
+ "seq_no_primary_term" ,
180
+ "size" ,
181
+ "slice" ,
182
+ "sort" ,
183
+ "source" ,
184
+ "stats" ,
185
+ "stored_fields" ,
186
+ "suggest" ,
187
+ "terminate_after" ,
188
+ "timeout" ,
189
+ "track_scores" ,
190
+ "track_total_hits" ,
191
+ "version" ,
192
+ ),
159
193
parameter_aliases = {
160
194
"_source" : "source" ,
161
195
"_source_excludes" : "source_excludes" ,
@@ -260,6 +294,7 @@ async def submit(
260
294
wait_for_completion_timeout : t .Optional [
261
295
t .Union ["t.Literal[-1]" , "t.Literal[0]" , str ]
262
296
] = None ,
297
+ body : t .Optional [t .Dict [str , t .Any ]] = None ,
263
298
) -> ObjectApiResponse [t .Any ]:
264
299
"""
265
300
Executes a search request asynchronously.
@@ -396,8 +431,8 @@ async def submit(
396
431
__path = f"/{ _quote (index )} /_async_search"
397
432
else :
398
433
__path = "/_async_search"
399
- __body : t .Dict [str , t .Any ] = {}
400
434
__query : t .Dict [str , t .Any ] = {}
435
+ __body : t .Dict [str , t .Any ] = body if body is not None else {}
401
436
# The 'sort' parameter with a colon can't be encoded to the body.
402
437
if sort is not None and (
403
438
(isinstance (sort , str ) and ":" in sort )
@@ -409,10 +444,6 @@ async def submit(
409
444
):
410
445
__query ["sort" ] = sort
411
446
sort = None
412
- if aggregations is not None :
413
- __body ["aggregations" ] = aggregations
414
- if aggs is not None :
415
- __body ["aggs" ] = aggs
416
447
if allow_no_indices is not None :
417
448
__query ["allow_no_indices" ] = allow_no_indices
418
449
if allow_partial_search_results is not None :
@@ -425,106 +456,54 @@ async def submit(
425
456
__query ["batched_reduce_size" ] = batched_reduce_size
426
457
if ccs_minimize_roundtrips is not None :
427
458
__query ["ccs_minimize_roundtrips" ] = ccs_minimize_roundtrips
428
- if collapse is not None :
429
- __body ["collapse" ] = collapse
430
459
if default_operator is not None :
431
460
__query ["default_operator" ] = default_operator
432
461
if df is not None :
433
462
__query ["df" ] = df
434
- if docvalue_fields is not None :
435
- __body ["docvalue_fields" ] = docvalue_fields
436
463
if error_trace is not None :
437
464
__query ["error_trace" ] = error_trace
438
465
if expand_wildcards is not None :
439
466
__query ["expand_wildcards" ] = expand_wildcards
440
- if explain is not None :
441
- __body ["explain" ] = explain
442
- if ext is not None :
443
- __body ["ext" ] = ext
444
- if fields is not None :
445
- __body ["fields" ] = fields
446
467
if filter_path is not None :
447
468
__query ["filter_path" ] = filter_path
448
- if from_ is not None :
449
- __body ["from" ] = from_
450
- if highlight is not None :
451
- __body ["highlight" ] = highlight
452
469
if human is not None :
453
470
__query ["human" ] = human
454
471
if ignore_throttled is not None :
455
472
__query ["ignore_throttled" ] = ignore_throttled
456
473
if ignore_unavailable is not None :
457
474
__query ["ignore_unavailable" ] = ignore_unavailable
458
- if indices_boost is not None :
459
- __body ["indices_boost" ] = indices_boost
460
475
if keep_alive is not None :
461
476
__query ["keep_alive" ] = keep_alive
462
477
if keep_on_completion is not None :
463
478
__query ["keep_on_completion" ] = keep_on_completion
464
- if knn is not None :
465
- __body ["knn" ] = knn
466
479
if lenient is not None :
467
480
__query ["lenient" ] = lenient
468
481
if max_concurrent_shard_requests is not None :
469
482
__query ["max_concurrent_shard_requests" ] = max_concurrent_shard_requests
470
483
if min_compatible_shard_node is not None :
471
484
__query ["min_compatible_shard_node" ] = min_compatible_shard_node
472
- if min_score is not None :
473
- __body ["min_score" ] = min_score
474
- if pit is not None :
475
- __body ["pit" ] = pit
476
- if post_filter is not None :
477
- __body ["post_filter" ] = post_filter
478
485
if pre_filter_shard_size is not None :
479
486
__query ["pre_filter_shard_size" ] = pre_filter_shard_size
480
487
if preference is not None :
481
488
__query ["preference" ] = preference
482
489
if pretty is not None :
483
490
__query ["pretty" ] = pretty
484
- if profile is not None :
485
- __body ["profile" ] = profile
486
491
if q is not None :
487
492
__query ["q" ] = q
488
- if query is not None :
489
- __body ["query" ] = query
490
493
if request_cache is not None :
491
494
__query ["request_cache" ] = request_cache
492
- if rescore is not None :
493
- __body ["rescore" ] = rescore
494
495
if rest_total_hits_as_int is not None :
495
496
__query ["rest_total_hits_as_int" ] = rest_total_hits_as_int
496
497
if routing is not None :
497
498
__query ["routing" ] = routing
498
- if runtime_mappings is not None :
499
- __body ["runtime_mappings" ] = runtime_mappings
500
- if script_fields is not None :
501
- __body ["script_fields" ] = script_fields
502
499
if scroll is not None :
503
500
__query ["scroll" ] = scroll
504
- if search_after is not None :
505
- __body ["search_after" ] = search_after
506
501
if search_type is not None :
507
502
__query ["search_type" ] = search_type
508
- if seq_no_primary_term is not None :
509
- __body ["seq_no_primary_term" ] = seq_no_primary_term
510
- if size is not None :
511
- __body ["size" ] = size
512
- if slice is not None :
513
- __body ["slice" ] = slice
514
- if sort is not None :
515
- __body ["sort" ] = sort
516
- if source is not None :
517
- __body ["_source" ] = source
518
503
if source_excludes is not None :
519
504
__query ["_source_excludes" ] = source_excludes
520
505
if source_includes is not None :
521
506
__query ["_source_includes" ] = source_includes
522
- if stats is not None :
523
- __body ["stats" ] = stats
524
- if stored_fields is not None :
525
- __body ["stored_fields" ] = stored_fields
526
- if suggest is not None :
527
- __body ["suggest" ] = suggest
528
507
if suggest_field is not None :
529
508
__query ["suggest_field" ] = suggest_field
530
509
if suggest_mode is not None :
@@ -533,20 +512,77 @@ async def submit(
533
512
__query ["suggest_size" ] = suggest_size
534
513
if suggest_text is not None :
535
514
__query ["suggest_text" ] = suggest_text
536
- if terminate_after is not None :
537
- __body ["terminate_after" ] = terminate_after
538
- if timeout is not None :
539
- __body ["timeout" ] = timeout
540
- if track_scores is not None :
541
- __body ["track_scores" ] = track_scores
542
- if track_total_hits is not None :
543
- __body ["track_total_hits" ] = track_total_hits
544
515
if typed_keys is not None :
545
516
__query ["typed_keys" ] = typed_keys
546
- if version is not None :
547
- __body ["version" ] = version
548
517
if wait_for_completion_timeout is not None :
549
518
__query ["wait_for_completion_timeout" ] = wait_for_completion_timeout
519
+ if not __body :
520
+ if aggregations is not None :
521
+ __body ["aggregations" ] = aggregations
522
+ if aggs is not None :
523
+ __body ["aggs" ] = aggs
524
+ if collapse is not None :
525
+ __body ["collapse" ] = collapse
526
+ if docvalue_fields is not None :
527
+ __body ["docvalue_fields" ] = docvalue_fields
528
+ if explain is not None :
529
+ __body ["explain" ] = explain
530
+ if ext is not None :
531
+ __body ["ext" ] = ext
532
+ if fields is not None :
533
+ __body ["fields" ] = fields
534
+ if from_ is not None :
535
+ __body ["from" ] = from_
536
+ if highlight is not None :
537
+ __body ["highlight" ] = highlight
538
+ if indices_boost is not None :
539
+ __body ["indices_boost" ] = indices_boost
540
+ if knn is not None :
541
+ __body ["knn" ] = knn
542
+ if min_score is not None :
543
+ __body ["min_score" ] = min_score
544
+ if pit is not None :
545
+ __body ["pit" ] = pit
546
+ if post_filter is not None :
547
+ __body ["post_filter" ] = post_filter
548
+ if profile is not None :
549
+ __body ["profile" ] = profile
550
+ if query is not None :
551
+ __body ["query" ] = query
552
+ if rescore is not None :
553
+ __body ["rescore" ] = rescore
554
+ if runtime_mappings is not None :
555
+ __body ["runtime_mappings" ] = runtime_mappings
556
+ if script_fields is not None :
557
+ __body ["script_fields" ] = script_fields
558
+ if search_after is not None :
559
+ __body ["search_after" ] = search_after
560
+ if seq_no_primary_term is not None :
561
+ __body ["seq_no_primary_term" ] = seq_no_primary_term
562
+ if size is not None :
563
+ __body ["size" ] = size
564
+ if slice is not None :
565
+ __body ["slice" ] = slice
566
+ if sort is not None :
567
+ __body ["sort" ] = sort
568
+ if source is not None :
569
+ __body ["_source" ] = source
570
+ if stats is not None :
571
+ __body ["stats" ] = stats
572
+ if stored_fields is not None :
573
+ __body ["stored_fields" ] = stored_fields
574
+ if suggest is not None :
575
+ __body ["suggest" ] = suggest
576
+ if terminate_after is not None :
577
+ __body ["terminate_after" ] = terminate_after
578
+ if timeout is not None :
579
+ __body ["timeout" ] = timeout
580
+ if track_scores is not None :
581
+ __body ["track_scores" ] = track_scores
582
+ if track_total_hits is not None :
583
+ __body ["track_total_hits" ] = track_total_hits
584
+ if version is not None :
585
+ __body ["version" ] = version
550
586
if not __body :
551
587
__body = None # type: ignore[assignment]
552
588
__headers = {"accept" : "application/json" }
0 commit comments