diff --git a/elastic/es_connect.py b/elastic/es_connect.py index ea8b974..0241f40 100644 --- a/elastic/es_connect.py +++ b/elastic/es_connect.py @@ -831,12 +831,8 @@ def get_user_by_username(username): def get_all_users(): """获取所有用户""" try: - search = UserDocument.search() - search = search.query("match_all") - response = search.execute() - users = [] - for hit in response: + for hit in UserDocument.search().query("match_all").scan(): users.append({ "user_id": hit.user_id, "username": hit.username, @@ -848,7 +844,6 @@ def get_all_users(): "key": list(getattr(hit, 'key', []) or []), "manage_key": list(getattr(hit, 'manage_key', []) or []), }) - return users except Exception as e: print(f"获取所有用户失败: {str(e)}")