From 3082199980426d54fde20a44551c0e69c054d583 Mon Sep 17 00:00:00 2001 From: koirand Date: Wed, 27 Mar 2019 02:24:43 +0900 Subject: [PATCH] Fix bug #19 --- assets/js/search.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/assets/js/search.js b/assets/js/search.js index d29fdbd..5737377 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -65,15 +65,16 @@ const queryNgramSeparator = (query) => { const initLunr = () => { $.getJSON('index.json').done((index) => { pagesIndex = index - lunrIndex = lunr(() => { - this.tokenizer = bigramTokeniser - this.pipeline.reset() - this.ref('ref') - this.field('title', { boost: 10 }) - this.field('body') - this.metadataWhitelist = ['position'] + lunrIndex = lunr(builder => { + console.log(builder) + builder.tokenizer = bigramTokeniser + builder.pipeline.reset() + builder.ref('ref') + builder.field('title', { boost: 10 }) + builder.field('body') + builder.metadataWhitelist = ['position'] for (let page of pagesIndex) { - this.add(page) + builder.add(page) } }) }).fail((jqxhr, textStatus, error) => { @@ -107,9 +108,9 @@ const initUI = () => { }) // Event when chenging query - $('#searchBoxInput').keyup(() => { + $('#searchBoxInput').keyup(event => { const $searchResults = $('#searchResults') - const query = $(this).val() + const query = $(event.currentTarget).val() // Icon switching if (query.length) {