diff --git a/example/config.json b/example/config.json index 3d4f9ae..e51dad3 100644 --- a/example/config.json +++ b/example/config.json @@ -47,11 +47,27 @@ { "field_weights": { - "url": 100, - "title": 200, - "description": 300, - "keywords": 400, - "body": 500 + "url":100, + "title":200, + "description":300, + "keywords":400, + "body":500 + } + }, + "highlight": + { + "fields": + [ + "url", + "title", + "description", + "keywords", + "body" + ], + "options": + { + "around":5, + "limit":140 } } }, diff --git a/src/webui/search.php b/src/webui/search.php index ec27fed..365d53d 100644 --- a/src/webui/search.php +++ b/src/webui/search.php @@ -169,6 +169,15 @@ foreach ($config->webui->search->options as $key => $value) } } +// Apply highlight options +if ($config->webui->search->highlight->fields) +{ + $query->highlight( + (array) $config->webui->search->highlight->fields, + (array) $config->webui->search->highlight->options + ); +} + // Get found $found = empty($q) ? $total : $query->get()->getTotal(); @@ -433,19 +442,38 @@ $results = $query->offset($p * $config->webui->pagination->limit - $config->webu ?> identicon - title)) { ?> + getHighlight()['title'])) { ?> + getHighlight()['title'] as $title) { ?> +
+

+
+ + title)) { ?>

title ?>

- description)) { ?> + getHighlight()['description'])) { ?> + getHighlight()['description'] as $description) { ?> +
+ + description)) { ?>
description ?>
- keywords)) { ?> + getHighlight()['keywords'])) { ?> + getHighlight()['keywords'] as $keywords) { ?> +
+ + keywords)) { ?>
keywords ?>
+ getHighlight()['body'])) { ?> + getHighlight()['body'] as $body) { ?> +
+ +
url)) ?> get('code'), [0, 200])) { ?>