-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 4.4.4
-
Component/s: Querying
-
None
-
Query Optimization
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
The captures are different when using RegExp vs // syntax.
Here's the output of a terminal session:
> db.foo.insert({job:"Engineering [122050] (open)"})
> db.foo.aggregate({$addFields: { returnObject: { $regexFind: { input: "$job", regex: RegExp('\[(.*)\]') }}}})
[ { _id: ObjectId("6060b22151a815916d99ba2f"),
job: 'Engineering [122050] (open)',
returnObject: { match: '(', idx: 21, captures: [] } } ]>
> db.foo.aggregate({$addFields: { returnObject: { $regexFind: { input: "$job", regex: /\[(.*)\]/} }}})
[ { _id: ObjectId("6060b22151a815916d99ba2f"),
job: 'Engineering [122050] (open)',
returnObject: { match: '[122050]', idx: 12, captures: [ '122050' ] } } ]
I am pretty sure that the syntax should be equivalent, but note the difference in the captures between the two queries. This is on an Atlas free tier (v4.4.4) cluster.
- related to
-
COMPASS-4737 Editing view causes $regexFind to be re-written
-
- Backlog
-