Tencent/WeKnora · error

source index data missing chunk_id field

Error message

source index data missing chunk_id field

What it means

Elasticsearch v7 reindex guard: the hit's _source object lacks a string 'chunk_id' field (missing or wrong type), so the source chunk cannot be mapped to its target chunk ID and the hit is rejected during copy/reindex processing.

Source

Thrown at internal/application/repository/retriever/elasticsearch/v7/repository.go:1172

	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 {
		log.Warnf("[ElasticsearchV7] Source index data missing knowledge_id field")
		return nil, nil, fmt.Errorf("source index data missing knowledge_id field")
	}

	targetKnowledgeID, ok := sourceToTargetKBIDMap[sourceKnowledgeID]
	if !ok {
		log.Warnf("[ElasticsearchV7] Source knowledge ID %s not found in mapping", sourceKnowledgeID)

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify the source index documents include chunk_id
  2. Re-index the source documents with correct field mapping
  3. Skip hits with absent chunk_id and log for reconciliation
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at internal/application/repository/retriever/elasticsearch/v7/repository.go:1172 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/bf8dab9105eb7f79. Report an issue: GitHub.