0
Match(csav:CSAVHierarchy) with csav


Match(cx:CXCustomerHierarchy) with cx

    Optional Match(csav)-[:CSAVCustomerHasChild]->(csa:CSAVHierarchy) where csa._type='CXCustomer' OR csa._type='CXCustomerBU'
    Optional Match(cx)-[:CXCustomerHasChild]->(cxc:CXCustomerHierarchy) where cxc._type='CXCustomer' OR  cxc._type='CXCustomerBU' 
    return
    CASE
    WHEN csa.ssid = cxc.ssid and csa.elementLabel = cxc.elementLabel
    THEN "yes"
    ELSE "No"  END As result

with this query its giving cartesian issue and i want to carry forward both the nodes data for further use.

where I m lacking?

Vartika
  • 1,085
  • 3
  • 17
  • 43

3 Answers3

3

You can use the Apoc plugin (see https://neo4j-contrib.github.io/neo4j-apoc-procedures):

Match(n:Person{ssid:"1234"}) with collect(n) as nodes CALL apoc.refactor.mergeNodes(nodes) YIELD node RETURN node
CIAndrews
  • 1,046
  • 10
  • 19
  • I am using commnunity edition for testing , how to install apoc procedure there – Vartika Mar 20 '19 at 08:55
  • You can place the jar (see https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases) in the plugins folder – CIAndrews Mar 20 '19 at 10:10
  • You can run `call apoc.help("apoc")` after restarting? If not, have a look here: https://stackoverflow.com/a/42741433/5785085 – CIAndrews Mar 20 '19 at 11:04
1

This query may do what you want. It returns the unique cxc and csa pairs that pass all your tests.

MATCH (csa:CSAVHierarchy)
WHERE
  (:CSAVHierarchy)-[:CSAVCustomerHasChild]->(csa) AND
  csa._type='CXCustomer' OR csa._type='CXCustomerBU'
MATCH (cxc:CXCustomerHierarchy)
WHERE
  (:CXCustomerHierarchy)-[:CXCustomerHasChild]->(cxc) AND
  csa.ssid = cxc.ssid AND
  csa.elementLabel = cxc.elementLabel AND
  (cxc._type='CXCustomer' OR  cxc._type='CXCustomerBU')
RETURN cxc, csa

For better performance, you should also create indexes on :CSAVHierarchy(_type) and :CXCustomerHierarchy(_type).

cybersam
  • 63,203
  • 6
  • 53
  • 76
0

This the solution I came up with

MATCH(cxc:CXCustomerHierarchy)-[:_properties]->(auditnode)-->(spoke)
 where cxc._type='CXCustomer' OR  cxc._type='CXCustomerBU' AND spoke.start_date <= 1554272198875 <= spoke.end_date AND spoke.status = "Confirmed"
 with cxc
 OPTIONAL MATCH (cxc)<-[r:CXCustomerHasChild]-(parent) with cxc
 MATCH(csav:CSAVHierarchy)-[:_properties]->(auditnode)-->(spoke) with cxc,csav
 where csav._type='CXCustomer' OR  csav._type='CXCustomerBU' AND spoke.start_date <= 1554272198875 <= spoke.end_date AND spoke.status = "Confirmed"
 OPTIONAL MATCH (csav)<-[r:CSAVCustomerHasChild]-(parent) with csav,cxc
return 
CASE
WHEN csav.sourceSystemId <> cxc.sourceSystemId , csav.elementLabel <> cxc.elementLabel
THEN csav.elementLabel
ELSE "SIMILAR DATA "  END As result
Vartika
  • 1,085
  • 3
  • 17
  • 43