Skip to content

Commit 6a36df0

Browse files
Merge pull request #545 from hellohaptik/BB-11092
(misc:) Log results from ES for chosen entities
2 parents 81aa200 + 81bc1d2 commit 6a36df0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ner_v2/detectors/textual/elastic_search.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,21 @@ def get_multi_entity_results(self, entities, texts, fuzziness_threshold=1,
129129
('TMOS', 'TMOS'), ('G.', 'G Pulla Reddy Sweets')])}
130130
]
131131
"""
132+
# entities for which es results need to be logged for debugging purposes
133+
log_results_for_entities = ['nsdc_language_select',
134+
'nsdc_choose_topik',
135+
'test_giftcard_user_amount',
136+
'pvr_giftcard_user_amount']
137+
# this boolean will determine if the es result needs to be logged
138+
# this will be set to true only if one of or all names mentioned in log_results_for_entities list
139+
# are present in the entities list
140+
log_es_result = False
141+
for entity_name in log_results_for_entities:
142+
if entity_name in entities:
143+
# if we find at least one entity name for which the es results need to be logged
144+
# we set the value for the boolean and break the loop
145+
log_es_result = True
146+
break
132147
request_timeout = self._connection_settings.get('request_timeout', 20)
133148
index_name = self._index_name
134149

@@ -143,6 +158,9 @@ def get_multi_entity_results(self, entities, texts, fuzziness_threshold=1,
143158
try:
144159
response = self._run_es_search(self._default_connection, **kwargs)
145160
results = _parse_multi_entity_es_results(response.get("responses"))
161+
if log_es_result:
162+
ner_logger.info(f'[ES Result for Entities] result: {results}')
163+
ner_logger.info(f'[ES Result for Entities] kwargs: {kwargs}')
146164
except es_exceptions.NotFoundError as e:
147165
raise DataStoreRequestException(f'NotFoundError in datastore query on index: {index_name}',
148166
engine='elasticsearch', request=json.dumps(data),

0 commit comments

Comments
 (0)