Is there any way to set default date range in elasticsearch

Is there any way in elasticsearch to set a default date range if to and from fields are null. Like whenever to and from are empty, then elasticsearch should perform search on the basis of defined default range. I have written a query but it only works in the case if to and from is defined:

"range": {
            "time": {
              "from": "2018-01-16T07:05:00",
              "to": "2018-01-16T10:59:09",
              "include_lower": true,
              "include_upper": true

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.