This commit is contained in:
2025-08-19 08:27:24 +08:00
parent 9ae7d6cf20
commit c23113a6f2

View File

@@ -42,11 +42,11 @@ def select_all_data(index_name):
print(f" 标签: {hit['_source'].get('tags', '')}") print(f" 标签: {hit['_source'].get('tags', '')}")
print(f" 时间戳: {hit['_source'].get('timestamp', '')}") print(f" 时间戳: {hit['_source'].get('timestamp', '')}")
# 在循环中添加打印完整数据结构的代码 # 在循环中添加打印完整数据结构的代码
if i == 1: # 只打印第一条数据的完整结构 # if i == 1: # 只打印第一条数据的完整结构
print("完整数据结构:") # print("完整数据结构:")
import pprint # import pprint
pp = pprint.PrettyPrinter(indent=4) # pp = pprint.PrettyPrinter(indent=4)
pp.pprint(hit['_source']) # pp.pprint(hit['_source'])
print("-" * 50) print("-" * 50)
except Exception as e: except Exception as e:
print(f"查询出错: {e}") print(f"查询出错: {e}")