-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
Fully Compatible
-
v8.0, v7.3
-
135
The question is if it should be valid for $jsonSchema to have properties with $. Update: confirmed that this is a valid case.
The error in BF-31616 is due to the fact that $jsonSchema directly parses into a match expression. If $jsonSchema has a property with $[name], the match expression that it is parsed to is not proper bson and is unable to be reparsed, causing errors in query stats (and possibly situations beyond query stats, either now or in the future).
ex. Original Query:
coll.find({ $jsonSchema: { properties: { $stdDevPop:
{ type: 'array' }
} } }, { _id: 1 }).sort({ _id: 1 }).toArray()
Parsed match expression:
{ $and: [ { $and: [ { $or: [ { $stdDevPop: { $not:
{ $exists: true }
} }, { $and: [ { $stdDevPop:
{ $_internalSchemaType: [ 4 ] }
} ] } ] } ] } ] }
On the re-parse, having $stdDevPop as a field name is not allowed.
error:
unknown top level operator: $stdDevPop. If you have a field name that starts with a '$' symbol, consider using $getField or $setField.
- related to
-
SERVER-89844 Make $jsonSchema with dollar fields in all keyword fields reparseable
- Closed