[Bug fix] fix bug found in regression when view chunks for document that not parsed in infinity, it would fail in UI (#14168)

### What problem does this PR solve?
See title, the fail image:
<img width="2667" height="915" alt="20260416-205718"
src="https://github.com/user-attachments/assets/0c564237-5ed0-49af-bf4c-d3b5519abc6e"
/>

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Wang Qi
2026-04-17 09:51:23 +08:00
committed by GitHub
parent f906a203bb
commit 96a23d2fd0

View File

@@ -491,17 +491,29 @@ class InfinityConnectionBase(DocStoreConnection):
return len(res)
def get_doc_ids(self, res: tuple[pd.DataFrame, int] | pd.DataFrame) -> list[str]:
# Extract DataFrame from result
if isinstance(res, tuple):
res = res[0]
return list(res["id"])
df, count = res
if count == 0:
return []
else:
df = res
return list(df["id"])
@abstractmethod
def get_fields(self, res: tuple[pd.DataFrame, int] | pd.DataFrame, fields: list[str]) -> dict[str, dict]:
raise NotImplementedError("Not implemented")
def get_highlight(self, res: tuple[pd.DataFrame, int] | pd.DataFrame, keywords: list[str], field_name: str):
# Extract DataFrame from result
if isinstance(res, tuple):
res = res[0]
df, _ = res
else:
df = res
if df.empty or field_name not in df.columns:
return {}
ans = {}
num_rows = len(res)
column_id = res["id"]