Mongodb Spring Mongo:将变量引用传递给StringOperators.Substr
我正在尝试将mongo投影操作转换为SpringMongodb Spring Mongo:将变量引用传递给StringOperators.Substr,mongodb,aggregation-framework,spring-data-mongodb,Mongodb,Aggregation Framework,Spring Data Mongodb,我正在尝试将mongo投影操作转换为Spring $project: { strippedRecord: { $let: { vars: { start: { $add: [ { $indexOfBytes: [ "$textRecord", "BLABLA" ] }, 1 ] }, end: { $st
$project: {
strippedRecord: {
$let: {
vars: {
start: { $add: [ { $indexOfBytes: [ "$textRecord", "BLABLA" ] }, 1 ] },
end: { $strLenBytes: "$textRecord" }
},
in: { $substr: [ "$textRecord", "$$start", { $subtract: [ "$$end", "$$start" ] } ] }
}
}
}
春天
project()
.and(Let.define(Let.ExpressionVariable
.newVariable("start")
.forExpression(
ArithmeticOperators.Add.valueOf(StringOperators.IndexOfBytes.valueOf("textRecord").indexOf("BLABLA")).add(1)
),
Let.ExpressionVariable
.newVariable("end")
.forExpression(
StringOperators.StrLenBytes.stringLengthOf("textRecord")
)
)
.andApply(**********)
).as("strippedRecord")
我试图使用下面的表达式来计算'************'部分的子字符串
StringOperators.Substr.valueOf("textRecord").substring()
但是,substring()方法只接受“int”。那么,在这里如何读取子字符串操作中的变量引用$$end,$$start呢