Skip to content

Commit

Permalink
clean up indexer
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanWelzel committed Jun 13, 2024
1 parent 2de0fde commit aa0eff2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/config_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
INDEX_CONFIG = {
"indexer_select": {
# default
None: "hub.dataindex.indexer.DrugIndexer",
None: "hub.dataindex.indexer.MyChemIndexer",
},
"env": {
"prod": {
Expand Down
22 changes: 4 additions & 18 deletions src/hub/dataindex/indexer.py
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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))

0 comments on commit aa0eff2

Please sign in to comment.