code: def delete_items(self, retention_time, time_field="metadata__updated_on"):
          
          if retention_time is None:
              logger.debug("[items retention] Retention policy disabled, no items will be deleted.")
              return
  
          if retention_time <= 0:
              logger.debug("[items retention] Minutes to retain must be greater than 0.")
              return
  
          before_date = get_diff_current_date(minutes=retention_time)
          before_date_str = before_date.isoformat()
  
          es_query = '''
                      {
                        "query": {
                          "range": {
                              "%s": {
                                  "lte": "%s"
                              }
                          }
                        }
                      }
                      ''' % (time_field, before_date_str)
  
          r = self.requests.post(self.index_url + "/_delete_by_query?refresh",
                                 data=es_query, headers=HEADER_JSON, verify=False)
          try:
              r.raise_for_status()
              r_json = r.json()
              logger.debug("[items retention] %s items deleted from %s before %s.",
                           r_json['deleted'], self.anonymize_url(self.index_url), before_date)
          except requests.exceptions.HTTPError as ex:
              logger.error("[items retention] Error deleted items from %s.", self.anonymize_url(self.index_url))
              logger.error(ex)
              return
docs: Delete documents updated before a given date
  
          :param retention_time: maximum number of minutes wrt the current date to retain the data
          :param time_field: time field to delete the data