From aa0eff2452284f4aa43a9ef476ad6d202c210b5a Mon Sep 17 00:00:00 2001 From: Dylan Welzel Date: Thu, 13 Jun 2024 16:53:20 -0700 Subject: [PATCH] clean up indexer --- src/config_hub.py | 2 +- src/hub/dataindex/indexer.py | 22 ++++------------------ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/config_hub.py b/src/config_hub.py index 7ffce53..deffd3d 100644 --- a/src/config_hub.py +++ b/src/config_hub.py @@ -10,7 +10,7 @@ INDEX_CONFIG = { "indexer_select": { # default - None: "hub.dataindex.indexer.DrugIndexer", + None: "hub.dataindex.indexer.MyChemIndexer", }, "env": { "prod": { diff --git a/src/hub/dataindex/indexer.py b/src/hub/dataindex/indexer.py index 280d6d5..e519f1d 100644 --- a/src/hub/dataindex/indexer.py +++ b/src/hub/dataindex/indexer.py @@ -1,10 +1,8 @@ -import logging from copy import deepcopy -from biothings.hub.dataindex.indexer import Indexer, IndexMappings +from biothings.hub.dataindex.indexer import Indexer DEFAULT_INDEX_MAPPINGS = { - "dynamic": "false", "properties": { "all": {"type": "text"}, "name": { @@ -22,26 +20,14 @@ } -class DrugIndexer(Indexer): +class MyChemIndexer(Indexer): def __init__(self, build_doc, indexer_env, index_name): super().__init__(build_doc, indexer_env, index_name) - self.logger.debug("Creating DrugIndexer") - # Log the original es index mappings - self.logger.debug("Original Index mappings: %s", - dict(self.es_index_mappings)) - - # Create a deep copy of the default index mappings new_mappings = deepcopy(DEFAULT_INDEX_MAPPINGS) - # Update the existing mappings with the new properties - if "properties" in self.es_index_mappings: - self.es_index_mappings["properties"].update( - new_mappings["properties"]) - else: - raise AttributeError( - "Unexpected structure for es_index_mappings: missing 'properties'") + self.es_index_mappings["properties"].update( + new_mappings["properties"]) - # Log the updated es index mappings self.logger.debug("Updated Index mappings: %s", dict(self.es_index_mappings))