Open alturkovic opened 1 month ago
Thank you for getting in touch.
Please do not feed the entire pipeline as a string. Aggregation#pipeline
accepts individual stages.
Also, there is this extra $
before each parameter binding, that is pushing the reader into scanUnquotedString
mode not suitable for data binding.
You may want to use something like timestamp: { $gte: ?0, $lte: ?1 }
to bind the given java.time
input parameter.
Please do not feed the entire pipeline as a string. Aggregation#pipeline accepts individual stages.
My bad, I did not notice the pipeline accepts multiple strings, thanks!
Also, there is this extra $ before each parameter binding, that is pushing the reader into scanUnquotedString mode not suitable for data binding.
Thank you, that helped also, I got confused by the JavaDoc example:
@Aggregation("{ '$group': { '_id' : '$lastname', names : { $addToSet : '$?0' } } }")
List<PersonAggregate> groupByLastnameAnd(String property);
Maybe it is just me, but a simpler aggregation pipeline (not using the property, but actual values) in the JavaDoc might prevent someone in the future from doing the same mistake I did.
Sorry for the noise and thank you for your time.
thank you for the feedback, glad it works for you now - yeah, makes sense to revisit the documentation.
I am trying to run the following MongoDB aggregation using Spring:
The query should find all documents in a time range and aggregate them using a specific time interval (the
?2
parameter).When I run this pipeline directly on Mongo using specific dates and mod parameter, everything works as expected. Example:
But, when I run this using Spring, I get the following exception:
I have tried wrapping the parameters, such as
'$?0'
but that did not work either, even though that is the format mentioned in@Aggregation
JavaDoc.What am I doing wrong? How do I pass these parameters correctly in my aggregation pipeline using Spring
@Aggregation
?