Return document from two array (unwind)

Good morning,
I should do a data extraction (Mongodb language) for a report my collation is composed like this

{"os": "windows 10",
"browserName": "firefox",
"result": "PASS",
[{"parentId": "", "testId": 1640,
"sessionTestId": "a3dafb7b-78a3-4850-9479-ec67c91f0d1a_US56739_ID1",
"description": "Description 1",
"userStoryId": 56739},
{"parentId": "", "testId": 1641,
"sessionTestId": "114ab7f8-b9b3-44b0-95a8-5f7f48f9d2c4_US56736_ID2",
"description": "Description 1",
"userStoryId": 56740}],
[{"parentId": "", "stepId": 1, "sessionTestId": "a3dafb7b-78a3-4850-9479-ec67c91f0d1a_US56739_ID1",
"name": "step01"},
{"parentId": "", "stepId": 1, "sessionTestId": "a3dafb7b-78a3-4850-9479-ec67c91f0d1a_US56739_ID1",
"name": "step02"},
{"parentId": "", "stepId": 2,"sessionTestId":  "114ab7f8-b9b3-44b0-95a8-5f7f48f9d2c4_US56736_ID2",
"name": "step01"},
{"parentId": "", "stepId": 2, "sessionTestId": "114ab7f8-b9b3-44b0-95a8-5f7f48f9d2c4_US56736_ID2",
"name": "step02"}]}

I should extract an output like this

"os": "windows 10", "browserName": "firefox", "result": "PASS", "tests.description": "Description 1", "tests.userStoryId": 56739, "": "step01","steps.stepId": 1
"os": "windows 10", "browserName": "firefox", "result": "PASS", "tests.description": "Description 1", "tests.userStoryId": 56739, "": "step02","steps.stepId": 1
"os": "windows 10", "browserName": "firefox", "result": "PASS", "tests.description": "Description 1", "tests.userStoryId": 56740, "": "step01","steps.stepId": 2
"os": "windows 10", "browserName": "firefox", "result": "PASS", "tests.description": "Description 1", "tests.userStoryId": 56740, "": "step02","steps.stepId": 2

between the two arrays I have the “sessionTestId” field as a link.

do you have an idea?

Hi @Fabio_Giusti ,

You need to unwind on tests and then use $project with $filter to show only relevant steps for each test.

If you need I can write the agg later on.