You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by ki...@apache.org on 2023/04/07 11:09:35 UTC
[jena-site] 02/03: Filter search results with uniq, add comments to search options, allow pages to be excluded from search
This is an automated email from the ASF dual-hosted git repository.
kinow pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena-site.git
commit 4b3a1e52c691db4457df7f2e40ab6949f9de9079
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
AuthorDate: Sun Feb 12 15:23:22 2023 +0100
Filter search results with uniq, add comments to search options, allow pages to be excluded from search
---
layouts/_default/index.json | 4 +++-
layouts/_default/search.html | 29 ++++++++++++++++++++++++-----
source/search/__index.md | 1 +
3 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/layouts/_default/index.json b/layouts/_default/index.json
index ae08324d8..f66614c96 100644
--- a/layouts/_default/index.json
+++ b/layouts/_default/index.json
@@ -1,5 +1,7 @@
{{- $.Scratch.Add "index" slice -}}
{{- range .Site.RegularPages -}}
+{{- if not .Params.excludeSearch -}}
{{- $.Scratch.Add "index" (dict "title" .Title "tags" .Params.tags "categories" .Params.categories "contents" .Plain "permalink" .Permalink) -}}
{{- end -}}
-{{- $.Scratch.Get "index" | jsonify -}}
+{{- end -}}
+{{- $.Scratch.Get "index" | uniq | jsonify -}}
diff --git a/layouts/_default/search.html b/layouts/_default/search.html
index 79af2183c..ba98c9870 100644
--- a/layouts/_default/search.html
+++ b/layouts/_default/search.html
@@ -21,20 +21,37 @@
<script type="text/javascript">
(function() {
const summaryInclude = 180;
+ // See: https://fusejs.io/api/options.html
const fuseOptions = {
+ // Whether to sort the result list, by score.
shouldSort: true,
+ // Whether the matches should be included in the result set.
+ // When true, each record in the result set will include the indices of the matched characters.
+ // These can consequently be used for highlighting purposes.
includeMatches: true,
+ // Whether the score should be included in the result set.
+ // A score of 0 indicates a perfect match, while a score of 1 indicates a complete mismatch.
includeScore: true,
- tokenize: true,
+ // Determines approximately where in the text is the pattern expected to be found.
location: 0,
+ // Determines how close the match must be to the fuzzy location (specified by location).
+ // An exact letter match which is distance characters away from the fuzzy location would
+ // score as a complete mismatch.
+ // A distance of 0 requires the match be at the exact location specified.
+ // A distance of 1000 would require a perfect match to be within 800 characters of the
+ // location to be found using a threshold of 0.8.
distance: 100,
- minMatchCharLength: 1,
+ // Only the matches whose length exceeds this value will be returned.
+ // (For instance, if you want to ignore single character matches in the result, set it to 2).
+ minMatchCharLength: 2,
+ // List of keys that will be searched.
+ // This supports nested paths, weighted search, searching in arrays of strings and objects.
keys: [
- {name: "title", weight: 0.45},
+ {name: "title", weight: 0.5},
{name: "contents", weight: 0.4},
- {name: "tags", weight: 0.1},
+ {name: "tags", weight: 0.95},
{name: "categories", weight: 0.05}
- ]
+ ],
};
// =============================
@@ -83,6 +100,8 @@
const searchQuery = document.getElementById("search-query").value;
const searchResults = document.getElementById("search-results");
+ searchResults.innerHTML += `<p>Search returned ${results.length} matches.</p>`;
+
// pull template from hugo template definition
const templateDefinition = document.getElementById("search-result-template").innerHTML;
diff --git a/source/search/__index.md b/source/search/__index.md
index ec17b86dc..23e5b539c 100644
--- a/source/search/__index.md
+++ b/source/search/__index.md
@@ -4,4 +4,5 @@ sitemap:
priority : 0.1
layout: "search"
slug: index
+excludeSearch: True
---