Exemplo n.º 1
0
    def get_es_count(cls, index, date=None):
        """Get elasticsearch count.

        Get count of items in elasticsearch for the given index.

        :param index: index.
        :return: items count.
        """
        try:
            query = RecordsSearch(index=index).query()
            if date:
                query = query.filter('range', _created={'lte': date})
            result = query.count()
        except NotFoundError:
            result = f'No >>{index}<< in ES'
        return result