I have an aggregation in a Spring Data MongoDB repository, using @Aggregation
annotation. Method has optional parameters, so I use SPEL to check input for nullability.
My question is: what is wrong with this expression?
"?#{ [10] == null ? {$expr: {$literal: true}} : {$or: [{'accountNumber': {$regex: [10]}}, {'target.properties.NAME': {$regex: [10]}} ]}}"
Getting this error:
org.springframework.expression.spel.SpelParseException: Expression [ [10] == null ? {$expr: {$literal: true}} : {$or: [{'accountNumber': {$regex: '[10]'}},{'target.properties.NAME': {$regex: '[10]'}} ]}] @86: EL1043E: Unexpected token. Expected 'rsquare(])' but was 'comma(,)'
I checked several times, and all the paranthesses and other stuff is fine.
For example, from the same aggregation, this expression is parsed well:
"?#{ [8] == null ? {$expr: {$literal: true}} : {'_id': { $in: [8] } } }"
Any ideas?
Tried to play with spaces, used ?10 instead of [10], but no luck
Yevhenii Filatov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.