docs: def terms_iterator_for_elasticsearch(fo: IO, index_name: str):
      """Add index_name to term documents for bulk load"""
  
      species_list = config["bel_resources"].get("species_list", [])
  
      fo.seek(0)  # Seek back to beginning of file
      with gzip.open(fo, "rt") as f:
          for line in f:
              term = json.loads(line)
              # skip if not term record (e.g. is a metadata record)
              if "term" not in term:
                  continue
              term = term["term"]
  
              # Filter species if enabled in config
              species_id = term.get("species_id", None)
              if species_list and species_id and species_id not in species_list:
                  continue
  
              all_term_ids = set()
              for term_id in [term["id"]] + term.get("alt_ids", []):
                  all_term_ids.add(term_id)
                  all_term_ids.add(lowercase_term_id(term_id))
  
              term["alt_ids"] = copy.copy(list(all_term_ids))
  
              yield {
                  "_op_type": "index",
                  "_index": index_name,
                  "_type": "term",
                  "_id": term["id"],
                  "_source": copy.deepcopy(term),
              }