Get the ids of existing input documents that match a query

def get_input_ids(query, limit=None):
    """Get the ids of existing input documents that match a query"""
    docs = scan(_es, index=esconfig.ES_INPUT_INDEX,
                doc_type=esconfig.ES_INPUT_DOCTYPE,
                query=query, size=(limit or 1000), fields="")
    for i, a in enumerate(docs):
        if limit and i >= limit:
            return
        yield a['_id']