Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug修复-Open search 查询结果错位问题 #2833

Merged
merged 25 commits into from
Oct 11, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6ca8e7f
添加favicon图片
May 9, 2024
870ea4e
Merge branch 'master' of https://github.com/hhyo/Archery
May 10, 2024
d24784d
Merge branch 'master' of https://github.com/hhyo/Archery
Jun 20, 2024
e80b335
firset
Jun 20, 2024
e4d02bb
修改
Jun 20, 2024
118504c
撤销
Jun 20, 2024
a4531d0
Merge branch 'master' of https://github.com/hhyo/Archery
Jun 21, 2024
7c2fea5
Merge branch 'master' of https://github.com/hhyo/Archery
Jun 27, 2024
64abe26
Merge branch 'master' of https://github.com/hhyo/Archery
Jul 31, 2024
bf3f327
Merge branch 'master' of https://github.com/hhyo/Archery
Aug 7, 2024
d23edba
Merge branch 'master' of https://github.com/hhyo/Archery
Aug 7, 2024
405b79e
Merge branch 'master' of https://github.com/hhyo/Archery
Aug 14, 2024
36bdde6
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 16, 2024
75edaf7
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 16, 2024
44230c0
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 19, 2024
d9bea16
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 20, 2024
09834da
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 28, 2024
aee2867
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Aug 30, 2024
dd0c01c
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Sep 2, 2024
a769d28
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Sep 19, 2024
c4734b7
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Sep 19, 2024
1598adc
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Sep 19, 2024
27d9f3d
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Sep 25, 2024
9814f28
Merge branch 'master' of https://github.com/hhyo/Archery
feiazifeiazi Oct 11, 2024
1a9bad1
解决列表问题
feiazifeiazi Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions sql/engines/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,29 +387,30 @@ def query(
hits = response.get("hits", {}).get("hits", [])
# 处理查询结果,将列表和字典转换为 JSON 字符串
rows = []
all_search_keys = {} # 用于收集所有字段的集合
all_search_keys["_id"] = None
for hit in hits:
# 获取文档 ID 和 _source 数据
doc_id = hit.get("_id")
source_data = hit.get("_source", {})

# 转换需要转换为 JSON 字符串的字段
for key, value in source_data.items():
all_search_keys[key] = None # 收集所有字段名
if isinstance(value, (list, dict)): # 如果字段是列表或字典
source_data[key] = json.dumps(value) # 转换为 JSON 字符串

# 构建结果行
row = {"_id": doc_id, **source_data}
rows.append(row)

# 如果有结果,获取字段名作为列名
if rows:
first_row = rows[0]
column_list = list(first_row.keys())
else:
column_list = []

column_list = list(all_search_keys.keys())
# 构建结果集
result_set.rows = [tuple(row.values()) for row in rows] # 只获取值
result_set.rows = []
for row in rows:
# 按照 column_list 的顺序填充每一行
result_row = tuple(row.get(key, None) for key in column_list)
result_set.rows.append(result_row)
result_set.column_list = column_list
result_set.affected_rows = len(result_set.rows)
return result_set
Expand Down
Loading