I have a aggregation flow in mongo spring which produce me following JSON (interesting sample only)
<code>"pages2":[
[
{
"_id":1,
</code>
<code>"pages2":[
[
{
"_id":1,
</code>
"pages2":[
[
{
"_id":1,
And thats the code which is responsible for building this part
<code>pipeline.add(addFields().addFieldWithValue("pages2", VariableOperators.mapItemsOf("pages")
.as("page")
.andApply(VariableOperators.mapItemsOf("$$page.elements").as("element")
.andApply(ArrayOperators.First.firstOf(ArrayOperators.Filter
.filter("$matche")
.as("matche")
.by(Eq.valueOf("$$matche.name")
.equalToValue(
"$$element.name"))))))
.build());
</code>
<code>pipeline.add(addFields().addFieldWithValue("pages2", VariableOperators.mapItemsOf("pages")
.as("page")
.andApply(VariableOperators.mapItemsOf("$$page.elements").as("element")
.andApply(ArrayOperators.First.firstOf(ArrayOperators.Filter
.filter("$matche")
.as("matche")
.by(Eq.valueOf("$$matche.name")
.equalToValue(
"$$element.name"))))))
.build());
</code>
pipeline.add(addFields().addFieldWithValue("pages2", VariableOperators.mapItemsOf("pages")
.as("page")
.andApply(VariableOperators.mapItemsOf("$$page.elements").as("element")
.andApply(ArrayOperators.First.firstOf(ArrayOperators.Filter
.filter("$matche")
.as("matche")
.by(Eq.valueOf("$$matche.name")
.equalToValue(
"$$element.name"))))))
.build());
Is there any option to make this code create something like this??
<code>"pages2":[
--> elements: [
{
"_id":1,
</code>
<code>"pages2":[
--> elements: [
{
"_id":1,
</code>
"pages2":[
--> elements: [
{
"_id":1,
Adding this “elements” string before an sub array. I’m out of ideas currenlty
Thanks
Marcin