Skip to content

Commit b4d5cef

Browse files
rikkt0rgithub-actions[bot]
authored andcommitted
Removed unnecessary filter argument in AggBase.__getitem__ (#1903)
* Remove excessive filter kwarg appearing in AggBase direct aggregation access (#1902) * Typo (#1902) (cherry picked from commit b06a222)
1 parent d5c5d42 commit b4d5cef

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: elasticsearch_dsl/aggs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __getitem__(self, agg_name: str) -> Agg[_R]:
127127
# make sure we're not mutating a shared state - whenever accessing a
128128
# bucket, return a shallow copy of it to be safe
129129
if isinstance(agg, Bucket):
130-
agg = A(agg.name, filter=None, **agg._params)
130+
agg = A(agg.name, **agg._params)
131131
# be sure to store the copy so any modifications to it will affect us
132132
self._params["aggs"][agg_name] = agg
133133

Diff for: tests/test_aggs.py

+9
Original file line numberDiff line numberDiff line change
@@ -476,3 +476,12 @@ def test_top_metrics_aggregation() -> None:
476476
assert {
477477
"top_metrics": {"metrics": {"field": "m"}, "sort": {"s": "desc"}}
478478
} == a.to_dict()
479+
480+
481+
def test_bucket_agg_with_filter() -> None:
482+
b = aggs.Filter(query.Terms(something=[1, 2, 3]))
483+
484+
a = aggs.Terms(field="some_field", size=100)
485+
a.bucket("b", b)
486+
487+
assert a.aggs["b"] == a["b"] # a['b'] threw exception before patch #1902

0 commit comments

Comments
 (0)