def get_doc_id_filter(doc_id_set):
    """
    This function returns a filter which removes any documents not in
    doc_id_set.

    This filter does not alter record_dict, but instead returns either true or
    false indicating whether to document should be kept or not.

    Parameters
    ----------
    doc_id_set : set

    Returns
    -------
    doc_id_filter : function

    Note
    ----
    It is recommended that this filter be used before any others in order to
    minimize unnecessary computations.
    """
    def doc_id_filter(record_dict):
        doc_id = record_dict['doc_id']
        keep_doc = doc_id in doc_id_set
        return keep_doc
    return doc_id_filter