From 96397b29d647e287601aa4b125a288ff6ea66f57 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 21 Mar 2024 22:05:47 +0200 Subject: [PATCH] add field_weights configuration --- example/config.json | 11 +++++++++++ src/webui/search.php | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/example/config.json b/example/config.json index 615efac..3d4f9ae 100644 --- a/example/config.json +++ b/example/config.json @@ -42,6 +42,17 @@ "extended": { "enabled":false + }, + "options": + { + "field_weights": + { + "url": 100, + "title": 200, + "description": 300, + "keywords": 400, + "body": 500 + } } }, "footer": diff --git a/src/webui/search.php b/src/webui/search.php index de68d38..4f85366 100644 --- a/src/webui/search.php +++ b/src/webui/search.php @@ -177,6 +177,26 @@ switch (true) } } +// Apply search options (e.g. field_weights) +foreach ($config->webui->search->options as $key => $value) +{ + if (is_int($value) || is_string($value)) + { + $query->option( + $key, + $value + ); + } + + else + { + $query->option( + $key, + (array) $value + ); + } +} + // Get found $found = empty($q) ? $total : $query->get()->getTotal();