Tencent/WeKnora · error

source knowledge ID %s not found in mapping

Error message

source knowledge ID %s not found in mapping

What it means

Elasticsearch v7 reindex mapping miss: the hit's knowledge_id is present but not found in the source-to-target KB ID map, so the document has no destination knowledge base in the copy operation and the hit is rejected as unmappable.

Source

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

	}

	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)
		return nil, nil, fmt.Errorf("source knowledge ID %s not found in mapping", sourceKnowledgeID)
	}

	// Extract basic content
	content, _ := sourceObj["content"].(string)
	originalSourceID, _ := sourceObj["source_id"].(string)
	sourceType := 0
	if st, ok := sourceObj["source_type"].(float64); ok {
		sourceType = int(st)
	}

	// Extract is_enabled (default true for backward compatibility)
	isEnabled := true
	if v, ok := sourceObj["is_enabled"].(bool); ok {
		isEnabled = v
	}

	// Extract is_recommended
	isRecommended := false

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Ensure the KB mapping covers all knowledge IDs present in the source index
  2. Rebuild the mapping if documents were added after it was computed
  3. Skip and reconcile unmapped documents in a later pass
Defensive patterns

Strategy: validation

When it happens

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