Add configuration option search_tokenizer_separator

The default is for hyphens to separate tokens in search terms: `gem-based` is equivalent to `gem based`.

This adds `search_tokenizer_separator` as a site configuation option, to support search for hyphenated words.
This commit is contained in:
Peter Mosses
2019-08-29 15:36:13 +02:00
parent ed492bf40e
commit 50cdf076b4
3 changed files with 15 additions and 1 deletions

View File

@@ -53,7 +53,7 @@ function initSearch() {
// Success!
var data = JSON.parse(request.responseText);
lunr.tokenizer.separator = /[\s\-/]+/
lunr.tokenizer.separator = {{ site.search_tokenizer_separator }}
var index = lunr(function () {
this.ref('id');
this.field('title', { boost: 200 });