Below is my query which i replicated using your query:
MATCH (a:DAY1)
OPTIONAL MATCH (b:DAY2)
WHERE a.CIRCUIT_ID=b.CIRCUIT_ID
WITH COLLECT({CIRCUIT_ID: a.CIRCUIT_ID, before:a, after:b}) AS res1
WITH [x IN res1 WHERE x.after IS NOT null | x.CIRCUIT_ID] AS includedXYZs, res1
MATCH (b:DAY2) WHERE NOT b.CIRCUIT_ID in includedXYZs
WITH res1 + COLLECT({CIRCUIT_ID: b.CIRCUIT_ID, before:null, after:b}) AS res
RETURN res
Output of the query:
{
"before": {
"CUSTOMER_ID": "9000180919",
"STATUS": "IN SERVICE",
"NEID": "INAPABJPXXXXTW6004ENBESR001",
"CIRCUIT_ID": "L3VPN_M_9000180919_900100000004_299355693011"
},
"CIRCUIT_ID": "L3VPN_M_9000180919_900100000004_299355693011",
"after": {
"CUSTOMER_ID": "9000180919",
"STATUS": "IN SERVICE",
"NEID": "INAPABJPXXXXTW6004ENBESR001",
"CIRCUIT_ID": "L3VPN_M_9000180919_900100000004_299355693011"
}
}
,============================================
{
"before": {
"CUSTOMER_ID": "9000111256",
"STATUS": "IN SERVICE",
"NEID": "INAPADNKADNKTW6002ENBESR001",
"CIRCUIT_ID": "L3VPN_M_9000111256_901400000012_299351118566"
},
"CIRCUIT_ID": "L3VPN_M_9000111256_901400000012_299351118566",
"after": null
}
,
{
"before": {
"CUSTOMER_ID": "9185360012",
"STATUS": "COMMISSIONED",
"NEID": "INAPAGRIXXXXTW0001ENBESR001",
"CIRCUIT_ID": "ILL_9185360012_299357344768"
},
"CIRCUIT_ID": "ILL_9185360012_299357344768",
"after": {
"CUSTOMER_ID": "9185360012",
"STATUS": "COMMISSIONED",
"NEID": "INAPAGRIXXXXTW0001ENBESR001",
"CIRCUIT_ID": "ILL_9185360012_299357344768"
}
}
,
{
"before": null,
"CIRCUIT_ID": "L3VPN_H_9000111256_901400000012_299351118566",
"after": {
"CUSTOMER_ID": "9000111256",
"STATUS": "IN SERVICE",
"NEID": "INAPADNKADNKTW6002ENBESR001",
"CIRCUIT_ID": "L3VPN_H_9000111256_901400000012_299351118566"
}
}
======= Expected Output=======
L3VPN_M_9000111256_901400000012_299351118566 { As this is the circuit id which not loaded in day2 label when compared to label day1.
Regards
Akshat