<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_elasticsearch(record, *args, **kwargs):
 """Return permission that check if the record exists in ES index. :params record: A record object. :returns: A object instance with a ``can()`` method. """

    def can(self):
        """Try to search for given record."""
        search = request._methodview.search_class()
        search = search.get_record(str(record.id))
        return search.count() == 1

    return type('CheckES', (), {'can': can})()