def METHOD_NAME(self):
    q = {
        "track_total_hits": True,
        "query": {
            "bool": {
                "must": [
                    {"term": {"status.exact": self.status}},
                    {"range": {"created_date": {"gte": self.from_date, "lte": self.to_date}}}
                ]
            }
        },
        "size": 10000
    }
    if self.action is not None:
        q['query']['bool']['must'].append({"term": {"action.exact": self.action}})
    return q