From e15a5e8a85d7af6b968367ae5cfebbe1afd0ad3a Mon Sep 17 00:00:00 2001 From: Taly Date: Tue, 30 Aug 2022 18:52:15 +0300 Subject: [PATCH] update --- src/backend/controllers/search.ts | 12 +++++------- src/frontend/js/modules/search.js | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/backend/controllers/search.ts b/src/backend/controllers/search.ts index adc56f5..f2f6566 100644 --- a/src/backend/controllers/search.ts +++ b/src/backend/controllers/search.ts @@ -61,11 +61,7 @@ class Search { throw error; } - const searchWords = searchString - .trim() - .toLowerCase() - .replace(/\s+/g, ' ') - .split(' '); + const searchWords = this.splitTextToWords(searchString); const goodPages = (await this.getPagesByWords(searchWords)) .slice(0, 10); @@ -182,9 +178,9 @@ class Search { private getBlockRatio(block: any) { switch (block.type) { case 'header': - return 6; + return 8; case 'paragraph': - return 2; + return 1.1; case 'list': return 1; default: @@ -240,6 +236,8 @@ class Search { // remove multiple spaces .replace(/\s+/g, ' ') + .trim() + // split to words by spaces .split(' ') diff --git a/src/frontend/js/modules/search.js b/src/frontend/js/modules/search.js index 034463a..21df71c 100644 --- a/src/frontend/js/modules/search.js +++ b/src/frontend/js/modules/search.js @@ -57,7 +57,7 @@ export default class Search { * - type a search string * - fire search */ - // const testString = 'api method'; + // const testString = 'access editor'; // this.toggleSearchOverlay(true); // this.nodes.searchInput.value = testString; // this.debouncedSearch(testString);