From 60e555b197fa0e47a8e194bf7b05097be99a5dcb Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Sun, 21 Jan 2024 20:00:33 +0100 Subject: [PATCH] Fixed crash with highlights and new index --- internal/webserver/controller/document/search.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/webserver/controller/document/search.go b/internal/webserver/controller/document/search.go index 1ab944f..4d0bac0 100644 --- a/internal/webserver/controller/document/search.go +++ b/internal/webserver/controller/document/search.go @@ -68,8 +68,10 @@ func (d *Controller) Search(c *fiber.Ctx) error { docsSortedByHighlightedDate := make([]index.Document, len(docs)) for i, path := range highlights.Hits() { - docsSortedByHighlightedDate[i] = docs[path] - docsSortedByHighlightedDate[i].Highlighted = true + if doc, ok := docs[path]; ok { + docsSortedByHighlightedDate[i] = doc + docsSortedByHighlightedDate[i].Highlighted = true + } } return c.Render("index", fiber.Map{