code: def check_elasticsearch(record, *args, **kwargs):
      
      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})()
docs: Return permission that check if the record exists in ES index.
  
      :params record: A record object.
      :returns: A object instance with a ``can()`` method.