fix: fix summary index bug.

This commit is contained in:
FFXN
2026-01-20 11:53:16 +08:00
parent 4fb08ae7d2
commit 008a5f361d
4 changed files with 63 additions and 46 deletions

View File

@ -437,6 +437,11 @@ class SummaryIndexService:
"""
Enable summary records and re-add vectors to vector database for segments.
Note: This method enables summaries based on chunk status, not summary_index_setting.enable.
The summary_index_setting.enable flag only controls automatic generation,
not whether existing summaries can be used.
Summary.enabled should always be kept in sync with chunk.enabled.
Args:
dataset: Dataset containing the segments
segment_ids: List of segment IDs to enable summaries for. If None, enable all.
@ -445,11 +450,6 @@ class SummaryIndexService:
if dataset.indexing_technique != "high_quality":
return
# Check if summary index is enabled
summary_index_setting = dataset.summary_index_setting
if not summary_index_setting or not summary_index_setting.get("enable"):
return
query = db.session.query(DocumentSegmentSummary).filter_by(
dataset_id=dataset.id,
enabled=False, # Only enable disabled summaries
@ -483,6 +483,7 @@ class SummaryIndexService:
.first()
)
# Summary.enabled stays in sync with chunk.enabled, only enable summary if the associated chunk is enabled.
if not segment or not segment.enabled or segment.status != "completed":
continue