0

I'm using Spring to generate a MongoDB pipeline, but want a $lookup operation with its own pipeline that Spring doesn't support. I've got a specialisation of AggregationOperation (similar to this Spring Data MongoDB Lookup with Pipeline Aggregation) which works, but if I try and do anything with the array I get from the lookup in a later Spring pipeline operation (e.g. unwind) I get an error when trying to run the aggregation that the field is invalid. If I write the same operation 'manually' as a custom pipeline operation, it works.

I've copied the generated pipeline text for both approaches into Compass and they're identical, so I'm not just making a typo in the naming. It's like the field from the custom step isn't available to the Spring steps.

Has anyone come across this access issue before?

jamiemcd
  • 23
  • 3

1 Answers1

0

My Answer was already in the comments of the question I'd linked to facepalm.

I needed to implement FieldsExposingAggregationOperation and FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation, and provide an override implementation for public ExposedFields getFields().

jamiemcd
  • 23
  • 3