diff --git a/pandagg/node/aggs/bucket.py b/pandagg/node/aggs/bucket.py index 07412c89..c07b4d5c 100644 --- a/pandagg/node/aggs/bucket.py +++ b/pandagg/node/aggs/bucket.py @@ -39,6 +39,8 @@ def __init__( class MatchAll(Filter): + KEY = "match_all" + def __init__(self, **body: Any): super(MatchAll, self).__init__(filter={"match_all": {}}, **body) diff --git a/pandagg/node/query/__init__.py b/pandagg/node/query/__init__.py index d9dedddf..90e2c4e4 100644 --- a/pandagg/node/query/__init__.py +++ b/pandagg/node/query/__init__.py @@ -4,6 +4,7 @@ from .full_text import * from .geo import * from .joining import * +from .match_all import * from .shape import * from .span import * from .specialized import * diff --git a/pandagg/node/query/match_all.py b/pandagg/node/query/match_all.py new file mode 100644 index 00000000..f4e12582 --- /dev/null +++ b/pandagg/node/query/match_all.py @@ -0,0 +1,18 @@ +from typing import Any + +from pandagg.node.query import LeafQueryClause + + +class MatchAll(LeafQueryClause): + + KEY = "match_all" + + def __init__(self, **body: Any) -> None: + super(MatchAll, self).__init__(**body) + + +class MatchNone(LeafQueryClause): + KEY = "match_none" + + def __init__(self, **body: Any) -> None: + super(MatchNone, self).__init__(**body) diff --git a/pandagg/query.py b/pandagg/query.py index f3f9b187..7eece7b7 100644 --- a/pandagg/query.py +++ b/pandagg/query.py @@ -31,6 +31,7 @@ DisMax, ) from pandagg.node.query.joining import Nested, HasChild, HasParent, ParentId +from pandagg.node.query.match_all import MatchNone, MatchAll from pandagg.node.query.geo import GeoShape, GeoPolygone, GeoDistance, GeoBoundingBox from pandagg.node.query.specialized import ( DistanceFeature, @@ -78,6 +79,9 @@ "HasParent", "HasChild", "ParentId", + # match_all + "MatchAll", + "MatchNone", # shape "Shape", # geo diff --git a/tests/node/query/test_match_all.py b/tests/node/query/test_match_all.py new file mode 100644 index 00000000..ed7bc540 --- /dev/null +++ b/tests/node/query/test_match_all.py @@ -0,0 +1,20 @@ +from pandagg.node.query import MatchAll, MatchNone + + +def test_match_all_clause(): + q = MatchAll() + assert q.body == {} + assert q.to_dict() == {"match_all": {}} + assert q.line_repr(depth=None) == ("match_all", "") + + q = MatchAll(boost=0.5) + assert q.body == {"boost": 0.5} + assert q.to_dict() == {"match_all": {"boost": 0.5}} + assert q.line_repr(depth=None) == ("match_all", "boost=0.5") + + +def test_match_none_clause(): + q = MatchNone() + assert q.body == {} + assert q.to_dict() == {"match_none": {}} + assert q.line_repr(depth=None) == ("match_none", "")