Fallback text seach on Asset/Billing
MODIFY
src/storage/mongodb/AssetStorage.ts
src/storage/mongodb/AssetStorage.ts
@@ -126,7 +126,10 @@ export default class AssetStorage {
const filters: FilterParams = {};
// Search
if (params.search) {
- filters.$text = { $search: params.search };
+ const searchRegex = Utils.escapeSpecialCharsInRegex(params.search);
+ filters.$or = [
+ { 'name': { $regex: searchRegex, $options: 'i' } },
+ ];
}
// With no Site Area
if (params.withNoSiteArea) {

MODIFY
src/storage/mongodb/BillingStorage.ts
src/storage/mongodb/BillingStorage.ts
@@ -57,8 +57,11 @@ export default class BillingStorage {
// Search filters
const filters: FilterParams = {};
// Search
+ // Filter by other properties
if (params.search) {
- filters.$text = { $search: params.search };
+ filters.$or = [
+ { 'number': { $regex: Utils.escapeSpecialCharsInRegex(params.search), $options: 'i' } }
+ ];
}
if (!Utils.isEmptyArray(params.invoiceIDs)) {
filters._id = {

Fallback text seach on Asset/Billing