Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Partial matching of strings in generateScientificExpression #680

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions common/models/mongo-queryable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";
const utils = require("./utils");
const lodash = require("lodash");
const escapeStringRegexp = require('escape-string-regexp')
module.exports = function (MongoQueryableModel) {

// to get access to other models
Expand Down Expand Up @@ -749,6 +750,23 @@ module.exports = function (MongoQueryableModel) {
});
break;
}
case "CONTAINS_STRING": {
const escapedRhs = escapeStringRegexp(rhs);
match.$and.push({
$or: [{
[matchKeyGeneric]: {
$regex: escapedRhs,
}
},
{
[`${matchKeyGeneric}.value`]: {
$regex: escapedRhs,
}
}
]
});
break;
}
case "EQUAL_TO_NUMERIC": {
if (unit.length > 0) {
const {
Expand Down