From 925b21823a2d68bc574540a5792b7f9a1bb0c097 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Mon, 8 Jun 2026 14:11:26 +0200 Subject: [PATCH] marshall explain output only in debug mode --- pkg/es/search.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/es/search.go b/pkg/es/search.go index 494f721..e171400 100644 --- a/pkg/es/search.go +++ b/pkg/es/search.go @@ -86,13 +86,12 @@ func explainSearch(conf *cfg.Config, search *search.Search) error { return fmt.Errorf("failed to call explain search (esdsl): %s", esErrorString(err)) } - raw, err := json.Marshal(res) - if err != nil { - return fmt.Errorf("failed to marshal explain result: %s", err) - } - if conf.Debug { - repr.Println(res) + raw, err := json.Marshal(res) + if err != nil { + return fmt.Errorf("failed to marshal explain result: %s", err) + } + value := gjson.Get(string(raw), "hits.hits.0._explanation") fmt.Println(value.String()) }