(query)
return ScanResult(query.count(), iter_export_docs())
Returns all docs which match query
Returns all docs which match query
Returns all docs which match query
def iter_es_docs_from_query(query):
    """Returns all docs which match query
    """
    scroll_result = query.scroll_ids()

    def iter_export_docs():
        with TransientTempfile() as temp_path:
            with open(temp_path, 'w', encoding='utf-8') as f:
                for doc_id in scroll_result:
                    f.write(doc_id + '\n')

            # Stream doc ids from disk and fetch documents from ES in chunks
            with open(temp_path, 'r', encoding='utf-8') as f:
                doc_ids = (doc_id.strip() for doc_id in f)
                for doc in iter_es_docs(query.index, doc_ids):
                    yield doc

    return ScanResult(query.count(), iter_export_docs())
def iter_es_docs_from_query ( query ) : scroll_result = query . scroll_ids ( ) def iter_export_docs ( ) : with TransientTempfile ( ) as temp_path : with open ( temp_path , 'w' , encoding = 'utf-8' ) as f : for doc_id in scroll_result : f . write ( doc_id + '\n' ) # Stream doc ids from disk and fetch documents from ES in chunks with open ( temp_path , 'r' , encoding = 'utf-8' ) as f : doc_ids = ( doc_id . strip ( ) for doc_id in f ) for doc in iter_es_docs ( query . index , doc_ids ) : yield doc return ScanResult ( query . count ( ) , iter_export_docs ( ) )