Skip to content

Commit

Permalink
feat: add disabled field type
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Sep 20, 2023
1 parent ba61103 commit 396750b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/cli/perform_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@ def perform_import(
# update with last index updates (hopefully since the jsonl)
get_redis_updates(next_index, config)
# make alias point to new index
update_alias(es, next_index)
update_alias(es, next_index, config.index.name)
4 changes: 4 additions & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class FieldType(StrEnum):
text = auto()
text_lang = auto()
taxonomy = auto()
# if the field is not enabled (=not indexed and not parsed), see:
# https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html
disabled = auto()


class FieldConfig(BaseModel):
Expand Down Expand Up @@ -219,6 +222,7 @@ def get_supported_langs(self) -> set[str]:
FieldConfig(name="ecoscore_grade", type=FieldType.keyword),
FieldConfig(name="nova_groups", type=FieldType.keyword),
FieldConfig(name="last_modified_t", type=FieldType.date),
FieldConfig(name="images", type=FieldType.disabled),
],
taxonomy=TaxonomyConfig(
sources=[
Expand Down
2 changes: 2 additions & 0 deletions app/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def generate_dsl_field(field: FieldConfig, supported_langs: Iterable[str]):
return Double(required=field.required, multi=field.multi)
elif field.type == FieldType.date:
return Date(required=field.required, multi=field.multi)
elif field.type == FieldType.disabled:
return Object(required=field.required, enabled=False)
else:
raise ValueError(f"unsupported field type: {field.type}")

Expand Down

0 comments on commit 396750b

Please sign in to comment.