Skip to content

Commit bb2c9b0

Browse files
Auto-generate aggregation classes (#1918) (#1926)
* auto-generate aggregation classes * feedback (cherry picked from commit ec8da55) Co-authored-by: Miguel Grinberg <[email protected]>
1 parent b116175 commit bb2c9b0

File tree

13 files changed

+5813
-1081
lines changed

13 files changed

+5813
-1081
lines changed

elasticsearch_dsl/aggs.py

+3,359-163
Large diffs are not rendered by default.

elasticsearch_dsl/query.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,9 @@ def __init__(
624624
Literal["multiply", "replace", "sum", "avg", "max", "min"], "DefaultType"
625625
] = DEFAULT,
626626
functions: Union[
627-
Sequence["types.FunctionScoreContainer"], Dict[str, Any], "DefaultType"
627+
Sequence["types.FunctionScoreContainer"],
628+
Sequence[Dict[str, Any]],
629+
"DefaultType",
628630
] = DEFAULT,
629631
max_boost: Union[float, "DefaultType"] = DEFAULT,
630632
min_score: Union[float, "DefaultType"] = DEFAULT,
@@ -1688,7 +1690,7 @@ def __init__(
16881690
organic: Union[Query, "DefaultType"] = DEFAULT,
16891691
ids: Union[Sequence[str], "DefaultType"] = DEFAULT,
16901692
docs: Union[
1691-
Sequence["types.PinnedDoc"], Dict[str, Any], "DefaultType"
1693+
Sequence["types.PinnedDoc"], Sequence[Dict[str, Any]], "DefaultType"
16921694
] = DEFAULT,
16931695
boost: Union[float, "DefaultType"] = DEFAULT,
16941696
_name: Union[str, "DefaultType"] = DEFAULT,
@@ -2372,7 +2374,7 @@ def __init__(
23722374
self,
23732375
*,
23742376
clauses: Union[
2375-
Sequence["types.SpanQuery"], Dict[str, Any], "DefaultType"
2377+
Sequence["types.SpanQuery"], Sequence[Dict[str, Any]], "DefaultType"
23762378
] = DEFAULT,
23772379
in_order: Union[bool, "DefaultType"] = DEFAULT,
23782380
slop: Union[int, "DefaultType"] = DEFAULT,
@@ -2459,7 +2461,7 @@ def __init__(
24592461
self,
24602462
*,
24612463
clauses: Union[
2462-
Sequence["types.SpanQuery"], Dict[str, Any], "DefaultType"
2464+
Sequence["types.SpanQuery"], Sequence[Dict[str, Any]], "DefaultType"
24632465
] = DEFAULT,
24642466
boost: Union[float, "DefaultType"] = DEFAULT,
24652467
_name: Union[str, "DefaultType"] = DEFAULT,

elasticsearch_dsl/search_base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ def to_dict(self, count: bool = False, **kwargs: Any) -> Dict[str, Any]:
949949
d = {}
950950

951951
if self.query:
952-
d["query"] = self.query.to_dict()
952+
d["query"] = recursive_to_dict(self.query)
953953

954954
if self._knn:
955955
if len(self._knn) == 1:
@@ -963,10 +963,10 @@ def to_dict(self, count: bool = False, **kwargs: Any) -> Dict[str, Any]:
963963
# count request doesn't care for sorting and other things
964964
if not count:
965965
if self.post_filter:
966-
d["post_filter"] = self.post_filter.to_dict()
966+
d["post_filter"] = recursive_to_dict(self.post_filter.to_dict())
967967

968968
if self.aggs.aggs:
969-
d.update(self.aggs.to_dict())
969+
d.update(recursive_to_dict(self.aggs.to_dict()))
970970

971971
if self._sort:
972972
d["sort"] = self._sort

0 commit comments

Comments
 (0)