You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert self.transform('elements HAS ONLY "H","He","Ga","Ta"') == { "elements": {"$all": ["H", "He", "Ga", "Ta"], "$size": 4} }
I
This suggests that "elements" has to contain all the elements "H", "He", "Ga", "Ta".
The OPTIMADE definition however is: " list HAS ONLY values: matches if all elements in list are equal to at least one value.
This suggest that {"elements": ["H", "He", "Ga"] should also be a valid.
The text was updated successfully, but these errors were encountered:
If both list and values do not contain duplicate values, this implements the <= set operator.
which is a handy summary.
HAS ONLY is an optional construct and I think optimade-python-tools is one of the few implementations to support it. This means we can decide to disable it, if it is going to be too arduous to support. Do you have any ideas on how to fix this? We could generate all possible subqueries (e.g. `{"$all": ["H"], "$size": 1} or {"$all": ["H", "He"], "$size": 2}... etc.) but this will get expensive for bigger queries and we might want to discourage it.
I think this query selects all documents where all elements are in the specified array ( ["H","He"] ). db.newtest.find({elements: {"$not": {"$elemMatch": {"$nin" : ["H","He"] }}}})
This query will however also pass documents with empty arrays. So an extra check may be necessary for this.
There is also $setIsSubset which would be more elegant. I however did not yet manage to create a proper query with this keyword. Perhaps it can't handle arrays with null values.
In test_mongo.py I noticed the following test:
assert self.transform('elements HAS ONLY "H","He","Ga","Ta"') == { "elements": {"$all": ["H", "He", "Ga", "Ta"], "$size": 4} }
I
This suggests that "elements" has to contain all the elements "H", "He", "Ga", "Ta".
The OPTIMADE definition however is: " list HAS ONLY values: matches if all elements in list are equal to at least one value.
This suggest that {"elements": ["H", "He", "Ga"] should also be a valid.
The text was updated successfully, but these errors were encountered: