Skip to content

Commit

Permalink
Auto-generate aggregation classes (#1918) (#1926)
Browse files Browse the repository at this point in the history
* auto-generate aggregation classes

* feedback

(cherry picked from commit ec8da55)

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
  • Loading branch information
github-actions[bot] and miguelgrinberg authored Oct 7, 2024
1 parent b116175 commit bb2c9b0
Show file tree
Hide file tree
Showing 13 changed files with 5,813 additions and 1,081 deletions.
3,522 changes: 3,359 additions & 163 deletions elasticsearch_dsl/aggs.py

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions elasticsearch_dsl/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ def __init__(
Literal["multiply", "replace", "sum", "avg", "max", "min"], "DefaultType"
] = DEFAULT,
functions: Union[
Sequence["types.FunctionScoreContainer"], Dict[str, Any], "DefaultType"
Sequence["types.FunctionScoreContainer"],
Sequence[Dict[str, Any]],
"DefaultType",
] = DEFAULT,
max_boost: Union[float, "DefaultType"] = DEFAULT,
min_score: Union[float, "DefaultType"] = DEFAULT,
Expand Down Expand Up @@ -1688,7 +1690,7 @@ def __init__(
organic: Union[Query, "DefaultType"] = DEFAULT,
ids: Union[Sequence[str], "DefaultType"] = DEFAULT,
docs: Union[
Sequence["types.PinnedDoc"], Dict[str, Any], "DefaultType"
Sequence["types.PinnedDoc"], Sequence[Dict[str, Any]], "DefaultType"
] = DEFAULT,
boost: Union[float, "DefaultType"] = DEFAULT,
_name: Union[str, "DefaultType"] = DEFAULT,
Expand Down Expand Up @@ -2372,7 +2374,7 @@ def __init__(
self,
*,
clauses: Union[
Sequence["types.SpanQuery"], Dict[str, Any], "DefaultType"
Sequence["types.SpanQuery"], Sequence[Dict[str, Any]], "DefaultType"
] = DEFAULT,
in_order: Union[bool, "DefaultType"] = DEFAULT,
slop: Union[int, "DefaultType"] = DEFAULT,
Expand Down Expand Up @@ -2459,7 +2461,7 @@ def __init__(
self,
*,
clauses: Union[
Sequence["types.SpanQuery"], Dict[str, Any], "DefaultType"
Sequence["types.SpanQuery"], Sequence[Dict[str, Any]], "DefaultType"
] = DEFAULT,
boost: Union[float, "DefaultType"] = DEFAULT,
_name: Union[str, "DefaultType"] = DEFAULT,
Expand Down
6 changes: 3 additions & 3 deletions elasticsearch_dsl/search_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ def to_dict(self, count: bool = False, **kwargs: Any) -> Dict[str, Any]:
d = {}

if self.query:
d["query"] = self.query.to_dict()
d["query"] = recursive_to_dict(self.query)

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

if self.aggs.aggs:
d.update(self.aggs.to_dict())
d.update(recursive_to_dict(self.aggs.to_dict()))

if self._sort:
d["sort"] = self._sort
Expand Down
Loading

0 comments on commit bb2c9b0

Please sign in to comment.