code: def refresh_identities(enrich_backend, author_field=None, author_values=None):
      
  
      def update_items(new_filter_author):
  
          for eitem in enrich_backend.fetch(new_filter_author):
              roles = None
              try:
                  roles = enrich_backend.roles
              except AttributeError:
                  pass
              new_identities = enrich_backend.get_item_sh_from_id(eitem, roles)
              eitem.update(new_identities)
              yield eitem
  
      logger.debug("Refreshing identities fields from %s",
                   enrich_backend.elastic.anonymize_url(enrich_backend.elastic.index_url))
  
      total = 0
  
      max_ids = enrich_backend.elastic.max_items_clause
      logger.debug('Refreshing identities')
  
      if author_field is None:
          # No filter, update all items
          for item in update_items(None):
              yield item
              total += 1
      else:
          to_refresh = []
          for author_value in author_values:
              to_refresh.append(author_value)
  
              if len(to_refresh) > max_ids:
                  filter_author = {"name": author_field,
                                   "value": to_refresh}
  
                  for item in update_items(filter_author):
                      yield item
                      total += 1
  
                  to_refresh = []
  
          if len(to_refresh) > 0:
              filter_author = {"name": author_field,
                               "value": to_refresh}
  
              for item in update_items(filter_author):
                  yield item
                  total += 1
  
      logger.info("Total eitems refreshed for identities fields %i", total)
docs: Refresh identities in enriched index.
  
      Retrieve items from the enriched index corresponding to enrich_backend,
      and update their identities information, with fresh data from the
      SortingHat database.
  
      Instead of the whole index, only items matching the filter_author
      filter are fitered, if that parameters is not None.
  
      :param enrich_backend: enriched backend to update
      :param  author_field: field to match items authored by a user
      :param  author_values: values of the authored field to match items