Tencent/WeKnora · error
elasticsearch update_by_query failed with status: %d
Error message
elasticsearch update_by_query failed with status: %d
What it means
Elasticsearch v7 update_by_query API returned an HTTP error status while batch-updating chunk enabled flags: the response body was decoded for details, but the overall bulk update failed and the error is propagated to the caller.
Source
Thrown at internal/application/repository/retriever/elasticsearch/v7/repository.go:1349
}
queryJSON, _ := json.Marshal(query)
res, err := esapi.UpdateByQueryRequest{
Index: []string{e.index},
Body: strings.NewReader(string(queryJSON)),
}.Do(ctx, e.client)
if err != nil {
log.Errorf("[ElasticsearchV7] Failed to update enabled chunks: %v", err)
return err
}
defer res.Body.Close()
if res.IsError() {
var e map[string]interface{}
if err := json.NewDecoder(res.Body).Decode(&e); err != nil {
log.Errorf("[ElasticsearchV7] Error parsing the response body: %v", err)
} else {
log.Errorf("[ElasticsearchV7] Error updating enabled chunks: %v", e["error"])
}
return fmt.Errorf("elasticsearch update_by_query failed with status: %d", res.StatusCode)
}
log.Infof("[ElasticsearchV7] Updated %d chunks to enabled", len(enabledChunkIDs))
}
// Batch update disabled chunks using update_by_query
if len(disabledChunkIDs) > 0 {
query := map[string]interface{}{
"query": map[string]interface{}{
"terms": map[string]interface{}{
e.idField("chunk_id"): disabledChunkIDs,
},
},
"script": map[string]interface{}{
"source": "ctx._source.is_enabled = false",
"lang": "painless",
},
}
queryJSON, _ := json.Marshal(query)View on GitHub (pinned to 988cbb0330)
Solutions
- Read the logged response body for the ES error reason
- Check index health and mapping compatibility
- Retry update_by_query after resolving conflicts/version issues
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/application/repository/retriever/elasticsearch/v7/repository.go:1349 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/b930dc74358a2c7d.
Report an issue: GitHub.