def METHOD_NAME(query: str, param_dict: Dict[str, Any]) -> str:
    """Replace parameters in query template for Elastic JSON queries."""
    query_dict = json.loads(query)
    start = param_dict.pop("start", None)
    end = param_dict.pop("end", None)
    if start or end:
        time_range = {
            "range": {"@timestamp": {"format": "strict_date_optional_time"}}
        }
        if start:
            time_range["range"]["@timestamp"]["gte"] = start
        if end:
            time_range["range"]["@timestamp"]["lte"] = end
        query_dict["query"]["bool"]["filter"].append(time_range)
    add_query_items = param_dict.pop("add_query_items", None)
    if add_query_items:
        # "add_query_items" expects additional custom filter parameters
        # as a Python dict (e.g. add_query_items={"match_phrase: {"field": "value"}})
        query_dict["query"]["bool"]["filter"].extend(add_query_items)
    if param_dict:
        filter_terms = [
            {"match_phrase": {field: value}} for field, value in param_dict.items()
        ]
        query_dict["query"]["bool"]["filter"].extend(filter_terms)
    return json.dumps(query_dict, indent=2)