Tencent/WeKnora · error
hit missing _source field
Error message
hit missing _source field
What it means
Elasticsearch v7 reindex guard: a search hit from the source index could not be decoded as a map containing a '_source' field, meaning the hit document is malformed or the index mapping changed; the per-hit processing aborts because required document fields cannot be read.
Source
Thrown at internal/application/repository/retriever/elasticsearch/v7/repository.go:1165
func (e *elasticsearchRepository) processSingleHit(ctx context.Context,
hit interface{},
sourceToTargetKBIDMap map[string]string,
sourceToTargetChunkIDMap map[string]string,
targetKnowledgeBaseID string,
) (*typesLocal.IndexInfo, []float32, error) {
log := logger.GetLogger(ctx)
hitMap, ok := hit.(map[string]interface{})
if !ok {
log.Warnf("[ElasticsearchV7] Invalid hit object format")
return nil, nil, fmt.Errorf("invalid hit object format")
}
// Get document source
sourceObj, ok := hitMap["_source"].(map[string]interface{})
if !ok {
log.Warnf("[ElasticsearchV7] Hit missing _source field")
return nil, nil, fmt.Errorf("hit missing _source field")
}
// Get source ChunkID and corresponding target ChunkID
sourceChunkID, ok := sourceObj["chunk_id"].(string)
if !ok {
log.Warnf("[ElasticsearchV7] Source index data missing chunk_id field")
return nil, nil, fmt.Errorf("source index data missing chunk_id field")
}
targetChunkID, ok := sourceToTargetChunkIDMap[sourceChunkID]
if !ok {
log.Warnf("[ElasticsearchV7] Source chunk ID %s not found in mapping", sourceChunkID)
return nil, nil, fmt.Errorf("source chunk ID %s not found in mapping", sourceChunkID)
}
// Get mapped target knowledge ID
sourceKnowledgeID, ok := sourceObj["knowledge_id"].(string)
if !ok {View on GitHub (pinned to 988cbb0330)
Solutions
- Inspect the raw hit JSON and source index mapping
- Skip malformed hits with a warning if partial reindexing is acceptable
- Verify the source index documents were written by a compatible version
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/application/repository/retriever/elasticsearch/v7/repository.go:1165 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/6cb5e9f107677645.
Report an issue: GitHub.