mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-09 00:51:42 +00:00
Add LRU to ES fqn (#9233)
This commit is contained in:
parent
0963eac48e
commit
2e1fb96751
@ -13,6 +13,7 @@ Mixin class containing Lineage specific methods
|
||||
|
||||
To be used by OpenMetadata class
|
||||
"""
|
||||
import functools
|
||||
import traceback
|
||||
from typing import Generic, List, Optional, Type, TypeVar
|
||||
|
||||
@ -38,6 +39,7 @@ class ESMixin(Generic[T]):
|
||||
|
||||
fqdn_search = "/search/query?q=fullyQualifiedName:{fqn}&from={from_}&size={size}&index={index}"
|
||||
|
||||
@functools.lru_cache()
|
||||
def _search_es_entity(
|
||||
self, entity_type: Type[T], query_string: str
|
||||
) -> Optional[List[T]]:
|
||||
@ -47,13 +49,13 @@ class ESMixin(Generic[T]):
|
||||
:param query_string: Query to run
|
||||
:return: List of Entities or None
|
||||
"""
|
||||
|
||||
response = self.client.get(query_string)
|
||||
|
||||
if response:
|
||||
return [
|
||||
self.get_by_name(
|
||||
entity=entity_type, fqn=hit["_source"]["fullyQualifiedName"]
|
||||
entity=entity_type,
|
||||
fqn=hit["_source"]["fullyQualifiedName"],
|
||||
)
|
||||
for hit in response["hits"]["hits"]
|
||||
] or None
|
||||
@ -84,12 +86,10 @@ class ESMixin(Generic[T]):
|
||||
)
|
||||
|
||||
try:
|
||||
entity_list = self._search_es_entity(
|
||||
response = self._search_es_entity(
|
||||
entity_type=entity_type, query_string=query_string
|
||||
)
|
||||
if entity_list:
|
||||
return entity_list
|
||||
|
||||
return response
|
||||
except KeyError as err:
|
||||
logger.debug(traceback.format_exc())
|
||||
logger.warning(
|
||||
|
Loading…
x
Reference in New Issue
Block a user