def add_operator(solr_Q1,solr_Q2,operator):
    """
    Function joins two Solr Qs with the correct operator

    :param solr_Q1: Solr Q object
    :param solr_Q2: Solr Q object
    :param operator: String, should be AND, OR, AND NOT
    """
    if solr_Q1 is not None and solr_Q2 is not None:
        if operator.strip() == 'AND NOT':
            return solr_Q1 & ~solr_Q2
        elif operator.strip() == 'OR':
            return solr_Q1 | solr_Q2
        # Defaults to AND
        else:
            return solr_Q1 & solr_Q2
    if solr_Q1 is not None and solr_Q2 is None:
        return solr_Q1
    if solr_Q1 is None and solr_Q2 is not None:
        return solr_Q2
    else:
        return None