From bba49df0e1adc68f1449bd8fbda6d6b375a6506d Mon Sep 17 00:00:00 2001 From: Mykola Golubyev Date: Sun, 29 Sep 2024 14:56:11 -0400 Subject: [PATCH] search: tweak lunrjs (#1236) --- znai-core/src/main/resources/lunrjs/indexCreation.js | 2 -- znai-reactjs/src/doc-elements/search/Search.js | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/znai-core/src/main/resources/lunrjs/indexCreation.js b/znai-core/src/main/resources/lunrjs/indexCreation.js index f16130490..3535350e5 100644 --- a/znai-core/src/main/resources/lunrjs/indexCreation.js +++ b/znai-core/src/main/resources/lunrjs/indexCreation.js @@ -37,8 +37,6 @@ var stopWordFilter = createStopWordFilter([ znaiSearchIdx = lunr(function () { this.pipeline.remove(lunr.stemmer) - this.pipeline.remove(lunr.stopWordFilter) - this.pipeline.add(stopWordFilter) this.ref('id') this.field('section') this.field('pageTitle') diff --git a/znai-reactjs/src/doc-elements/search/Search.js b/znai-reactjs/src/doc-elements/search/Search.js index b1ec827f2..b4345b1d5 100644 --- a/znai-reactjs/src/doc-elements/search/Search.js +++ b/znai-reactjs/src/doc-elements/search/Search.js @@ -37,9 +37,9 @@ class Search { const lowestBoost = 0.05 const matches = this.searchIdx.query(q => { term.split(lunr.tokenizer.separator).forEach(function (term) { - // if (term.length <= 2) { - // return - // } + if (term.length <= 2) { + return + } q.term(term, { fields: [ 'pageTitle' ], boost: highestBoost }) q.term(term, { fields: [ 'pageSection' ], boost: highestBoost })