this.queryResponseFilter = ' unwind nodes(p) as asset' +
' unwind relationships(p) as relationsp' +
' optional match p2=(asset)-[:HAS_EVENT]->(e:EVENT)' +
' unwind relationships(p2) as relationsp2' +
' return collect(distinct asset)+collect(DISTINCT e) as distinctNodes, collect(DISTINCT relationsp)+collect(DISTINCT relationsp2) as distinctRelationships'
this.queryStrBack = 'match p=(n:ASSET{uniqueID: $uniqueID})<-[TRANSFORMS_INTO*]-()-[:HAS_EVENT]->()' + this.queryResponseFilter
this.queryStrForward = 'match p=(n:ASSET{uniqueID: $uniqueID})-[TRANSFORMS_INTO*]->()-[:HAS_EVENT]->()' + this.queryResponseFilter
this.finalQueryForward = this.queryStrForward + ' UNION ' + this.queryStrBack
let result = await session.run( this.finalQueryForward , { uniqueID }, {timeout:0});
here result i am only getting from query before UNION
here is the response
{
records: [
Record {
keys: [Array],
length: 2,
_fields: [Array],
_fieldLookup: [Object]
},
Record {
keys: [Array],
length: 2,
_fields: [Array],
_fieldLookup: [Object]
}
],
summary: ResultSummary {
query: {
text: 'match p=(n:ASSET{uniqueID: $uniqueID})-[TRANSFORMS_INTO*]->()-[:HAS_EVENT]->() unwind nodes(p) as asset unwind relationships(p) as relationsp optional match p2=(asset)-[:HAS_EVENT]->(e:EVENT) unwind relationships(p2) as relationsp2 return collect(distinct asset)+collect(DISTINCT e) as distinctNodes, collect(DISTINCT relationsp)+collect(DISTINCT relationsp2) as distinctRelationships UNION match p=(n:ASSET{uniqueID: $uniqueID})<-[TRANSFORMS_INTO*]-()-[:HAS_EVENT]->() unwind nodes(p) as asset unwind relationships(p) as relationsp optional match p2=(asset)-[:HAS_EVENT]->(e:EVENT) unwind relationships(p2) as relationsp2 return collect(distinct asset)+collect(DISTINCT e) as distinctNodes, collect(DISTINCT relationsp)+collect(DISTINCT relationsp2) as distinctRelationships',
parameters: [Object]
},
queryType: 'r',
counters: QueryStatistics { _stats: [Object], _systemUpdates: 0 },
updateStatistics: QueryStatistics { _stats: [Object], _systemUpdates: 0 },
plan: false,
profile: false,
notifications: ,
server: ServerInfo {
address: 'localhost:7687',
agent: 'Neo4j/5.2.0',
protocolVersion: 5
},
resultConsumedAfter: Integer { low: 9, high: 0 },
resultAvailableAfter: Integer { low: 59, high: 0 },
database: { name: 'neo4j' }
}
}
when i try to hit in neo4j desktop
its working fine
but from code only getting response query written before UNION