code: def enrich_items(self, ocean_backend, events=False):
          max_items = self.elastic.max_items_bulk
          current = 0
          total = 0
          bulk_json = ""
          items = ocean_backend.fetch()
          images_items = {}
          url = self.elastic.index_url + '/items/_bulk'
          logger.debug("Adding items to %s (in %i packs)", self.elastic.anonymize_url(url), max_items)
          for item in items:
              if current >= max_items:
                  total += self.elastic.safe_put_bulk(url, bulk_json)
                  json_size = sys.getsizeof(bulk_json) / (1024 * 1024)
                  logger.debug("Added %i items to %s (%0.2f MB)", total, self.elastic.anonymize_url(url), json_size)
                  bulk_json = ""
                  current = 0
              rich_item = self.get_rich_item(item)
              data_json = json.dumps(rich_item)
              bulk_json += '{"index" : {"_id" : "%s" } }\n' % \
                  (item[self.get_field_unique_id()])
              bulk_json += data_json + "\n"
              current += 1
              if rich_item['id'] not in images_items:
                  rich_item['is_docker_image'] = 1
                  rich_item['is_event'] = 0
                  images_items[rich_item['id']] = rich_item
              else:
                  image_date = images_items[rich_item['id']]['last_updated']
                  if image_date <= rich_item['last_updated']:
                      rich_item['is_docker_image'] = 1
                      rich_item['is_event'] = 0
                      images_items[rich_item['id']] = rich_item
          if current > 0:
              total += self.elastic.safe_put_bulk(url, bulk_json)
          if total == 0:
              return total
          for image in images_items:
              data = images_items[image]
              data_json = json.dumps(data)
              bulk_json += '{"index" : {"_id" : "%s" } }\n' % \
                  (data['id'] + "_image")
              bulk_json += data_json + "\n"
          total += self.elastic.safe_put_bulk(url, bulk_json)
          return total