Skip to content

Commit

Permalink
Concepts/Mapping updated by dynamic string mapping for ES
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Oct 11, 2023
1 parent b484e4f commit 7b20ee3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions core/concepts/documents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django_elasticsearch_dsl import Document, fields
from django_elasticsearch_dsl.registries import registry
from elasticsearch_dsl import MetaField

from core.common.utils import jsonify_safe, flatten_dict
from core.concepts.models import Concept
Expand All @@ -11,13 +12,16 @@ class Index:
name = 'concepts'
settings = {'number_of_shards': 1, 'number_of_replicas': 0}

class Meta:
dynamic = MetaField('strict')

id = fields.TextField(attr='mnemonic')
id_lowercase = fields.KeywordField(attr='mnemonic', normalizer="lowercase", dynamic='strict')
id_lowercase = fields.KeywordField(attr='mnemonic', normalizer="lowercase")
numeric_id = fields.LongField()
name = fields.TextField()
_name = fields.KeywordField(attr='display_name', normalizer='lowercase')
last_update = fields.DateField(attr='updated_at')
updated_by = fields.KeywordField(attr='updated_by.username', dynamic='strict')
updated_by = fields.KeywordField(attr='updated_by.username')
locale = fields.ListField(fields.KeywordField())
synonyms = fields.ListField(fields.TextField())
source = fields.KeywordField(attr='parent_resource', normalizer="lowercase")
Expand Down
6 changes: 5 additions & 1 deletion core/mappings/documents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django_elasticsearch_dsl import Document, fields
from django_elasticsearch_dsl.registries import registry
from elasticsearch_dsl import MetaField
from pydash import get

from core.common.utils import jsonify_safe, flatten_dict
Expand All @@ -18,8 +19,11 @@ class Django:
'external_id'
]

class Meta:
dynamic = MetaField('strict')

last_update = fields.DateField(attr='updated_at')
updated_by = fields.KeywordField(attr='updated_by.username', dynamic='strict')
updated_by = fields.KeywordField(attr='updated_by.username')
owner = fields.KeywordField(attr='owner_name', normalizer="lowercase")
owner_type = fields.KeywordField(attr='owner_type')
source = fields.KeywordField(attr='source', normalizer="lowercase")
Expand Down

0 comments on commit 7b20ee3

Please sign in to comment.