// This file is autogenerated, DO NOT EDIT
// aggregations/bucket/daterange-aggregation.asciidoc:305

[source, python]
----
resp = client.search(
    index="sales",
    size="0",
    aggs={
        "range": {
            "date_range": {
                "field": "date",
                "format": "MM-yyy",
                "ranges": [
                    {
                        "to": "now-10M/M"
                    },
                    {
                        "from": "now-10M/M"
                    }
                ],
                "keyed": True
            }
        }
    },
)
print(resp)
----
