I have the cypher below, the case is with first entry in someList:
{ id: 'some_id1', a: [ 'a1' ], r: [] },
If I return a list containing .r ... i get 4 elements (right count), if i return .a, I get 3 elements (this first one is missing) ... and if I return the variables - they are null.
I've been iterating and tried nested calls to see if i could figure out why, not sure if necessary.
WITH [
{ actual: "abcde-51e6-4ef0-9549-c3304f42664e", proposed: "abcde-51e6-4ef0-9549-c3304f42554e" },
{ actual: "three-066e-4a48-9a7c-2ec1a36d6d1e", proposed: "three-066e-4a48-9a7c-2ec1a36d6d1e" },
{ actual: "091282f32-51e6-4ef0-9549-c3304f42664e", proposed: "091282f32-51e6-4ef0-9549-c3304f42664e" },
{ actual: "five-066e-4a48-9a7c-2ec1a36d6d1w", proposed: "five-066e-4a48-9a7c-2ec1a36d6d1w" },
{ actual: "08182f32-51e6-4ef0-9549-c3304f42664e", proposed: "08182f32-51e6-4ef0-9549-c3304f42664e" },
{ actual: "four-066e-4a48-9a7c-2ec1a36d6d1e", proposed: "four-066e-4a48-9a7c-2ec1a36d6d1e" },
{ actual: "alpha-066e-4a48-9a7c-2ec1a36d6d2f", proposed: "alpha-066e-4a48-9a7c-2ec1a36d6d2f" },
{ actual: "beta-066e-4a48-9a7c-2ec1a36d6d2f", proposed: "beta-066e-4a48-9a7c-2ec1a36d6d2f" },
{ actual: "betagamma-066e-4a48-9a7c-2ec1a36d6d2f", proposed: "betagamma-066e-4a48-9a7c-2ec1a36d6d2f" },
{ actual: "epsilon-066e-4a48-9a7c-2ec1a36d6d2f", proposed: "epsilon-066e-4a48-9a7c-2ec1a36d6d2f" }
] AS listOfValues
$someList: [
{
id: 'some_id1',
a: [ 'a1' ],
r: []
},
{
id: 'some_id2,
a: [ 'a1', 'a2' ],
r: [ 'epsilon-066e-4a48-9a7c-2ec1a36d6d2f', 'four-066e-4a48-9a7c-2ec1a36d6d1e' ]
},
{
id: 'some_id3',
a: [ 'a2' ],
r: [ 'epsilon-066e-4a48-9a7c-2ec1a36d6d2f', 'beta-066e-4a48-9a7c-2ec1a36d6d2f' ]
},
{
id: 'some_id4',
a: [ 'a1', 'a2' ],
r: [ 'five-066e-4a48-9a7c-2ec1a36d6d1w', 'beta-066e-4a48-9a7c-2ec1a36d6d2f' ]
}
]
UNWIND $someList AS someElement
WITH someElement, listOfValues
CALL {
WITH someElement, listOfValues
// First make refinement safe and check if we should process
WITH
someElement,
listOfValues,
COALESCE(someElement.r, []) AS safeR
// Main processing block - preserves context
WITH someElement, listOfValues, safeR
CALL {
WITH someElement, listOfValues, safeR
// Only process if we have refinements to match
WITH someElement, listOfValues, safeR
WHERE size(safeR) > 0
// Find matching pairs
UNWIND listOfValues AS pair
WITH pair
WHERE pair.proposed IN safeR
RETURN pair.actual AS theActual
}
WITH someElement, listOfValues, COLLECT(theActual) AS matchedActuals
RETURN someElement as SOA, listOfValues AS loV, COALESCE(someElement.a, []) + COALESCE(matchedActuals, []) AS allInterests
}
// Final output with all context preserved
RETURN
COALESCE(allInterests, COALESCE(someElement.a, [])) AS result