'Filter results with (without, when `neg == True`) a
screenshot (on a specific `port` if specified).
`words` can be specified as a string, a regular expression, a
boolean, or as a list and is/are matched against the OCR
results. When `words` is specified and `neg == True`, the
result will filter results **with** a screenshot **without**
the word(s) in the OCR results.'

@staticmethod
def searchscreenshot(port=None, protocol='tcp', service=None, words=None, neg=False):

    result = {'ports': {'$elemMatch': {}}}
    if (words is None):
        if ((port is None) and (service is None)):
            return {'ports.screenshot': {'$exists': (not neg)}}
        result['ports']['$elemMatch']['screenshot'] = {'$exists': (not neg)}
    else:
        result['ports']['$elemMatch']['screenshot'] = {'$exists': True}
        if isinstance(words, list):
            words = {('$ne' if neg else '$all'): words}
        elif isinstance(words, utils.REGEXP_T):
            words = ({'$not': words} if neg else words)
        elif isinstance(words, bool):
            words = {'$exists': words}
        else:
            words = ({'$ne': words} if neg else words)
        result['ports']['$elemMatch']['screenwords'] = words
    if (port is not None):
        result['ports']['$elemMatch']['port'] = port
        result['ports']['$elemMatch']['protocol'] = protocol
    if (service is not None):
        result['ports']['$elemMatch']['service_name'] = service
    return result
