全新 WeKnora 会用空映射({})先建好索引,范围字段等第一次写入才动态生成。
首次同步在读目标当前状态时就报 "missing release scope fields" 并失败,等于
"往空的生产实例做第一次同步"这条路根本走不通。
现在:"没有范围字段 + 索引确实 0 篇文档" = 空基线;有文档却看不出归属仍然报错
(绝不把无法归属的文档当空库覆盖)。Count 与整库导出共用同一判断。
试过:make verify 15 项全绿;新增空/非空两种索引的用例;真实 sync 复现原错误。
This commit is contained in:
@@ -26,6 +26,22 @@ func (e *SearchExporter) ExportLibrary(ctx context.Context, identity SearchIdent
|
||||
}
|
||||
return SearchSnapshot{Documents: []SearchDocument{}, MappingSHA256: "", DocumentsSHA256: emptyDigest}, nil
|
||||
}
|
||||
if errors.Is(err, errScopeFieldsMissing) {
|
||||
// 全新实例先用空映射建索引:没有范围字段、又确实 0 篇文档时就是空基线;
|
||||
// 有文档却看不出归属必须报错(不能当成空库覆盖)。
|
||||
empty, probeErr := e.emptyScopeIndex(ctx)
|
||||
if probeErr != nil {
|
||||
return SearchSnapshot{}, probeErr
|
||||
}
|
||||
if empty {
|
||||
emptyDigest, digestErr := searchDocumentsDigest([]SearchDocument{})
|
||||
if digestErr != nil {
|
||||
return SearchSnapshot{}, digestErr
|
||||
}
|
||||
return SearchSnapshot{Documents: []SearchDocument{}, MappingSHA256: "", DocumentsSHA256: emptyDigest}, nil
|
||||
}
|
||||
return SearchSnapshot{}, err
|
||||
}
|
||||
if err != nil {
|
||||
return SearchSnapshot{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user