-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial matching of strings in generateScientificExpression #119
Partial matching of strings in generateScientificExpression #119
Conversation
@@ -96,6 +97,11 @@ export const mapScientificQuery = ( | |||
scientificFilterQuery[`${matchKeyGeneric}.value`] = { $eq: rhs }; | |||
break; | |||
} | |||
case ScientificRelation.CONTAINS_STRING: { | |||
const escapedRhs = escapeStringRegexp(rhs); | |||
scientificFilterQuery[`${matchKeyGeneric}.value`] = { $eq: escapedRhs }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henrikjohansson712 : compared to the old backend the generation of the ScientificExpression looks much simpler.
Does the new backend impose to always have value
as item for every entry in the scientific metadata, or did I get a wrong impression there? (a.k.a are simple entries without value
/unit
no longer supported through the new backend?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont know what is currently implemented, but it must be possible to define data without the value/unit Syntax. If its not supported, it must be added.
@stephan271 can you please provide an example of a scientificMetadata without value/unit? |
At ESS, we always have value and unit. |
At MAXIV we also only have unit and value for physical quantities. Others will only have value. |
@linupi are you able to update the code to include the case when the scientific metadata entry is a string and not a object with fields value and unit? |
I could for sure adopt the code proposed in here, but I am wondering if it is not a more general issue since the existence of a src/common/utils.ts:20: return { valueSI: Number(quantity.value), unitSI: quantity.unit }; src/common/utils.ts:92: const matchKeyMeasurement = `scientificMetadata.${lhs}.valueSI`; src/common/utils.ts:97: scientificFilterQuery[`${matchKeyGeneric}.value`] = { $eq: rhs }; src/common/utils.ts:102: scientificFilterQuery[`${matchKeyGeneric}.value`] = { $eq: escapedRhs }; src/common/utils.ts:111: scientificFilterQuery[`${matchKeyGeneric}.value`] = { $eq: rhs }; src/common/utils.ts:121: scientificFilterQuery[`${matchKeyGeneric}.value`] = { $gt: rhs }; src/common/utils.ts:131: scientificFilterQuery[`${matchKeyGeneric}.value`] = { $lt: rhs }; src/datasets/interceptors/fullquery.interceptor.ts:34: `${lhs}.value`, src/datasets/interceptors/fullquery.interceptor.ts:46: `${lhs}.value`, wouldn't it make sense to provide a more generic helper to deal with the different options of having |
@linupi should I merge this branch in to master? |
We should close this PR as I included the changes in #1293. |
Port of SciCatProject/backend-v3#680 to the new backend!
Description
This PR adds an additional
CONTAINS_STRING
condition to thegenerateScientificExpression
function to filter within strings in scientific metadata.Motivation
When defining our meta data schemas we realized that it would be very helpful for us to also filter on partially matching strings in the scientific metadata. However, so far there is only
EQUAL_TO_STRING
for text based entries in scientific metadata so we propose an additionalCONTAINS_STRING
which should work on simple strings as well as on lists. Here is an example:The idea of the proposed
CONTAINS_STRING
is that it would match e.g.John
in both cases (aslocalContact
as well as inexperimentalists
)Changes:
generateScientificExpression
inmongo-queryable.js
Tests included/Docs Updated?