(field, value)
Filter docs by a field
    'value' can be a singleton or a list.
Filter docs by a field
    'value' can be a singleton or a list.
Filter docs by a field value can be a singleton or a list .
def term(field, value):
    """
    Filter docs by a field
    'value' can be a singleton or a list.
    """
    if isinstance(value, list):
        return {"terms": {field: value}}
    elif isinstance(value, tuple):
        return {"terms": {field: list(value)}}
    elif isinstance(value, set):
        return {"terms": {field: list(value)}}
    else:
        return {"term": {field: value}}
def term ( field , value ) : if isinstance ( value , list ) : return { "terms" : { field : value } } elif isinstance ( value , tuple ) : return { "terms" : { field : list ( value ) } } elif isinstance ( value , set ) : return { "terms" : { field : list ( value ) } } else : return { "term" : { field : value } }