def METHOD_NAME(args):
    logger.info("exporting from index `{}`".format(audit.get_index_name()))
    starttime = datetime.datetime.now()
    logger.info("fetching resultset with scroll time of `{}`".format(args.scrolltime))
    query = {"query": {'match_all': {}}}
    size = hps.hps_get_number_of_matches(audit.get_index_name(), query)
    if size < 0:
        logger.info('unknown number of items to export')
    else:
        logger.info("{} items need to be exported".format(size))
    results, _, scroll_id = hps.hps_get_data(
        audit.get_index_name(),
        query,
        sort='date:desc',
        scroll=args.scrolltime,
        size=10000,  # max per search result
        timeout=args.searchtimeout)
    logger.info("writing to `{}` (truncated)".format(args.filepath))
    with open(args.filepath, 'w') as output:
        writer = csv.writer(output, quoting=csv.QUOTE_ALL)
        logger.info("writing header row...")
        writer.writerow(['date', 'name', 'object', 'path', 'request_uri', 'summary', 'type', 'user'])
        num = 0
        while len(results) > 0:
            old_scroll_id = scroll_id
            logger.info("writing {} hits for scroll {}".format(len(results), old_scroll_id))
            for result in results:
                data = result['_source']
                rowdata = [
                    data.get("date", ""),
                    data.get("name", ""),
                    data.get("object", ""),
                    data.get("path", ""),
                    data.get("request_uri", ""),
                    data.get("summary", ""),
                    data.get("type", ""),
                    data.get("user", ""),
                ]
                rowdata = [convertunicode(a) for a in rowdata]
                writer.writerow(rowdata)
            num += len(results)
            logger.info("{} of {} written".format(num, size))
            logger.info("fetching next scroll...")
            results, _, old_scroll_id = hps.hps_get_scroll(scroll_id=old_scroll_id, scroll=args.scrolltime)
    endtime = datetime.datetime.now()
    deltatime = endtime - starttime
    logger.info("export complete -- took {}s, exported {} records".format(deltatime.total_seconds(), num))