def check_index()

in src/es_pii_tool/helpers/elastic_api.py [0:0]


def check_index(client: 'Elasticsearch', index_name: str, job_config: t.Dict) -> None:
    """Check the index"""
    logger.info('Making a quick check on redacted index docs...')
    result = do_search(client, index_name, job_config['query'])
    if result['hits']['total']['value'] == 0:
        logger.warning(
            'Query returned no results, assuming it only returns docs '
            'to be redacted and not already redacted...'
        )
        return
    success = check_fields(result, job_config)
    if not success:
        msg = 'One or more fields were not redacted. Check the logs'
        logger.error(msg)
        raise ValueMismatch(msg, 'count of fields matching query is not 0', '0')