Skip to content

Commit

Permalink
Flatten hierarchy_radio fields during record transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
nascosto committed Oct 30, 2024
1 parent b00e656 commit a570590
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scraper/src/typesense_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ def transform_record(record):
+ transformed_record['weight']['position_descending']
)

# Flatten nested hierarchy field
# Flatten nested hierarchy fields
for x in range(0, 7):
if record['hierarchy'][f'lvl{x}'] is None:
continue
transformed_record[f'hierarchy.lvl{x}'] = record['hierarchy'][f'lvl{x}']
if record['hierarchy'][f'lvl{x}'] is not None:
transformed_record[f'hierarchy.lvl{x}'] = record['hierarchy'][f'lvl{x}']
if record['hierarchy_radio'][f'lvl{x}'] is not None:
transformed_record[f'hierarchy_radio.lvl{x}'] = record['hierarchy_radio'][f'lvl{x}']

# Convert version to array
if 'version' in record and type(record['version']) == str:
Expand Down

0 comments on commit a570590

Please sign in to comment.