From 922fde070166898cbde561739670e1249423abe2 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 19 Oct 2022 23:25:46 +0700 Subject: [PATCH] Fixed search boost not being applied to document sections --- material/plugins/search/plugin.py | 5 +++-- src/plugins/search/plugin.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/material/plugins/search/plugin.py b/material/plugins/search/plugin.py index 71da0cb50..62683d4d2 100644 --- a/material/plugins/search/plugin.py +++ b/material/plugins/search/plugin.py @@ -45,11 +45,11 @@ class SearchIndex(BaseIndex): def add_entry_from_context(self, page): index = len(self._entries) super().add_entry_from_context(page) - entry = self._entries[index] # Add document tags, if any if page.meta.get("tags"): if type(page.meta["tags"]) is list: + entry = self._entries[index] entry["tags"] = [ str(tag) for tag in page.meta["tags"] ] @@ -64,7 +64,8 @@ class SearchIndex(BaseIndex): if "search" in page.meta: search = page.meta["search"] if "boost" in search: - entry["boost"] = search["boost"] + for entry in self._entries[index:]: + entry["boost"] = search["boost"] # ----------------------------------------------------------------------------- # Data diff --git a/src/plugins/search/plugin.py b/src/plugins/search/plugin.py index 71da0cb50..62683d4d2 100644 --- a/src/plugins/search/plugin.py +++ b/src/plugins/search/plugin.py @@ -45,11 +45,11 @@ class SearchIndex(BaseIndex): def add_entry_from_context(self, page): index = len(self._entries) super().add_entry_from_context(page) - entry = self._entries[index] # Add document tags, if any if page.meta.get("tags"): if type(page.meta["tags"]) is list: + entry = self._entries[index] entry["tags"] = [ str(tag) for tag in page.meta["tags"] ] @@ -64,7 +64,8 @@ class SearchIndex(BaseIndex): if "search" in page.meta: search = page.meta["search"] if "boost" in search: - entry["boost"] = search["boost"] + for entry in self._entries[index:]: + entry["boost"] = search["boost"] # ----------------------------------------------------------------------------- # Data