From 462f4e560cfbf2faaaf11112ec121e601cd4cc22 Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Fri, 12 Jul 2019 14:25:55 +0900 Subject: [PATCH] use case insensitive search. --- src/database/lib/AdvancedSearchQuery.ts | 4 ++-- src/database/lib/ItemUtil.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/database/lib/AdvancedSearchQuery.ts b/src/database/lib/AdvancedSearchQuery.ts index 7b8a35a..2b528f8 100644 --- a/src/database/lib/AdvancedSearchQuery.ts +++ b/src/database/lib/AdvancedSearchQuery.ts @@ -81,9 +81,9 @@ class AdvancedSearchQuery { // }; // filter2.push({ file: { '$elemMatch': filter3 } }); filter2.push({ 'file.file_type_name': fileType }); - filter2.push({ ['file.' + subKey]: { '$regex': regex } }); + filter2.push({ ['file.' + subKey]: { '$regex': [regex, 'i'] } }); } else { - filter2.push({ [key]: { '$regex': regex } }); + filter2.push({ [key]: { '$regex': [regex, 'i'] } }); } }); filter.push({ '$and': filter2 }); diff --git a/src/database/lib/ItemUtil.ts b/src/database/lib/ItemUtil.ts index 05a437a..09dee33 100644 --- a/src/database/lib/ItemUtil.ts +++ b/src/database/lib/ItemUtil.ts @@ -556,7 +556,7 @@ class ItemUtil { let nKeys: string[] = basicNumKeys.concat(numKeys); sKeys.forEach((key) => { let criteria: any = {}; - criteria[key] = { '$regex': regex }; + criteria[key] = { '$regex': [regex, 'i'] }; filterItemType['$or'].push(criteria); }); if (num !== null) { @@ -569,8 +569,8 @@ class ItemUtil { filter['$or'].push(filterItemType); } if (type === 'basic') { - filter['$or'].push({ 'title': { '$regex': regex } }); - filter['$or'].push({ 'keyword': { '$regex': regex } }); + filter['$or'].push({ 'title': { '$regex': [regex, 'i'] } }); + filter['$or'].push({ 'keyword': { '$regex': [regex, 'i'] } }); } else { if (type === 'all' || type === 'binder') { const strKeys: string[] = ['doi', 'title', 'keyword', 'description'];