import logging


def construct_filter_string(filters, filter_name, suffix):
    """
    Constructs a query string for a given filter. E.g with suffix = 'OR' and filter_name = 'subject' with the subjects
    'work' and 'report' the query generated would be 'subject: work OR report'
    """
    filter_string = ''
    try:
        filter_string = ' %s:\"%s\"' % (filter_name, filters.pop())
        for filter_s in filters:
            filter_string += ' %s \"%s\"' % (suffix, filter_s)
        return filter_string
    except Exception as ex:
        logging.exception('Construct Filter String Exception : %s' % ex)
    return filter_string