allow quoted searches

This commit is contained in:
Jason Wall 2020-08-01 23:59:44 -04:00
parent f95bf62cdb
commit 528855895d
2 changed files with 8 additions and 7 deletions

View File

@ -52,10 +52,6 @@ export class SearchPage extends SubscriberComponent
this.appService.getAutoComplete(value.toLowerCase())
)
);
this.cards$.subscribe((state) => {
console.log('Cards updated...');
});
}
ngAfterViewInit(): void {

View File

@ -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) {