def get_field_matches(explain, index_fields):
    """
    Iterates over the toString output of the Lucene explain object to parse
    out which fields generated the current hit. Returns a list containing all
    fields involved in generating this hit
    """
    match_fields = set()

    for line in explain.split('\n'):
        if line.find('fieldNorm') != -1:
            field_name = line.split('field=')[1].split(',')[0]
            if field_name in index_fields: match_fields.add(field_name)

    return match_fields