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