Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Commit 6374958

Browse files
hatemosphereclaude
andcommitted
refactor: derive log row id from hit _index/_id when available
Prefer the hit's own identifiers over a synthetic row index, matching how Grafana's built-in Elasticsearch datasource builds LogRowModel.uid. Falls back to the row index when _index/_id are missing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d0e57a6 commit 6374958

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

pkg/quickwit/response_parser.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,19 @@ func processLogsResponse(res *es.SearchResponse, target *Query, configuredFields
151151
// Always set a unique id per row. Grafana's virtualized log panel uses
152152
// LogRowModel.uid (derived from the "id" field) as a cache key for
153153
// row height measurements. Without unique ids, rows sharing the same
154-
// cache key cause an infinite resetAfterIndex loop. The source index
155-
// may have an "id" field with non-unique values, so always overwrite.
156-
doc["id"] = fmt.Sprintf("%d", hitIdx)
154+
// cache key cause an infinite resetAfterIndex loop. Prefer the hit's
155+
// own _index/_id when present (matches built-in ES datasource), fall
156+
// back to the row index otherwise.
157+
hitIndex, _ := hit["_index"].(string)
158+
hitID, _ := hit["_id"].(string)
159+
switch {
160+
case hitIndex != "" && hitID != "":
161+
doc["id"] = hitIndex + "#" + hitID
162+
case hitID != "":
163+
doc["id"] = hitID
164+
default:
165+
doc["id"] = strconv.Itoa(hitIdx)
166+
}
157167

158168
docs[hitIdx] = doc
159169
}

0 commit comments

Comments
 (0)