From 528855895d5e86b59c8e281ccebe5bc2f4212c68 Mon Sep 17 00:00:00 2001 From: Jason Wall Date: Sat, 1 Aug 2020 23:59:44 -0400 Subject: [PATCH] allow quoted searches --- .../app/search/components/search-page/search.page.ts | 4 ---- app/db/src/app/services/app.service.ts | 11 ++++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/db/src/app/search/components/search-page/search.page.ts b/app/db/src/app/search/components/search-page/search.page.ts index 6bff31ef..65faeae3 100644 --- a/app/db/src/app/search/components/search-page/search.page.ts +++ b/app/db/src/app/search/components/search-page/search.page.ts @@ -52,10 +52,6 @@ export class SearchPage extends SubscriberComponent this.appService.getAutoComplete(value.toLowerCase()) ) ); - - this.cards$.subscribe((state) => { - console.log('Cards updated...'); - }); } ngAfterViewInit(): void { diff --git a/app/db/src/app/services/app.service.ts b/app/db/src/app/services/app.service.ts index 12587862..10a022d2 100644 --- a/app/db/src/app/services/app.service.ts +++ b/app/db/src/app/services/app.service.ts @@ -636,7 +636,11 @@ export class AppService extends createStateService(reducer, initialState) { }); return; } - const stem = this.wordToStem.get(q); + + const stem = + q.startsWith('"') && q.endsWith('"') + ? q.split('"').join('') // if its quoted, search the exact term. + : this.wordToStem.get(q); // otherwise use the stem to get a broader set of results. // handle the first case. if (stem <= this.searchIndexArray[0]) { @@ -649,8 +653,7 @@ export class AppService extends createStateService(reducer, initialState) { break; } - // For each query term, figure out which xml file it is in, and get it. - // getSearchRefs returns an array of references. + // For each query term, figure out which file it is in, and get it. for (let w = 1; w < this.searchIndexArray.length; w++) { // If we are at the end of the array, we want to use a different test. if ( @@ -1066,6 +1069,8 @@ export class AppService extends createStateService(reducer, initialState) { prefix = keyword.substr(0, idx).trim() + '; '; } + qry = qry.split('"').join(''); // remove any quotes, just in case + if (qry.search(/[0-9]/i) === -1) { // its a word for (const item of BibleReference.Books) {