MCPcopy Index your code
hub / github.com/dataease/SQLBot / get_es_fields

Function get_es_fields

backend/apps/db/es_engine.py:57–75  ·  view source on GitHub ↗
(conf: DatasourceConf, table_name: str)

Source from the content-addressed store, hash-verified

55
56# get fields
57def get_es_fields(conf: DatasourceConf, table_name: str):
58 es_client = get_es_connect(conf)
59 index_name = table_name
60 mapping = es_client.indices.get_mapping(index=index_name)
61 properties = mapping.get(index_name).get("mappings").get("properties")
62 res = []
63 if properties is not None:
64 for field, config in properties.items():
65 field_type = config.get("type")
66 desc = ''
67 if config.get("_meta"):
68 desc = config.get("_meta").get('description')
69
70 if field_type:
71 res.append((field, field_type, desc))
72 else:
73 # object、nested...
74 res.append((field, ','.join(list(config.keys())), desc))
75 return res
76
77
78# def get_es_data(conf: DatasourceConf, sql: str, table_name: str):

Callers 1

get_fieldsFunction · 0.90

Calls 6

get_es_connectFunction · 0.85
listFunction · 0.85
getMethod · 0.65
itemsMethod · 0.45
appendMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected