Welcome to the community! You should be able to return the path with something like this:
MATCH (p:Product {id: WhateverYourID})
MATCH (w:Warehouse {id:Whatever})
MATCH path = (w)-[:RECEIVES]->(p)-[*]->(your final node destination here)
RETURN path
It doesn't matter that it goes through the same airport, you just need the individual shipment or item id and you can track it this way. Here's a link to Matching in Neo4j that includes paths as well as a similar question to yours How do you return all distinct full paths?. I hope this helps.
MATCH (p:Product {id:"1"})
MATCH (w:Warehouse {name:"Mywarehouse"})
MATCH path = (w)-[:RECEIVES]->(p)<-[*..7]-(:Supplier)
RETURN path
Question do I need to introduce a property called productID in each relationship, to track which path was taken for a product or is there any simpler way to track this.
Also, if you are shipping many products from the same supplier on the same date , then you create a new branch from (date) node to create a second product delivery path.
I agree its a better model but doesn't solve the purpose completely.
For example if i select Product2 it would return me BOTH Warehouse1 and Warehouse2 (Picture below) as there is a common airport along the path, which is not correct as product 1,2 belong to Warehouse1 and product 3 belongs to Warehouse2
Also, this is just a small sample data there might be several other common airport along the path.
Do we have to attach a product ID along the path i.e. at Airport Node or Relationship Node?
The problem here is that all products from different suppliers go to the same final destination airport, "Perth", but the product and warehouse information is not available at the final destination or at any other airports. Accordingly, the system is showing all the warehouses available at the final destination. You should pass the BOL info from airport to airport. Only then the final airport can connect the correct product to the correct warehouse.
Assuming Supplier 1 ships to WareHouse1 and Supplier 2 sends to WareHouse2:
Try this:
match path = (a:Supplier)-[]-(p:Product)-[*..10]-(w:Warehouse)
where a.name = "Supplier1" and p.name = "Product 1" and w.name = "WareHouse1"
return path
I agree we need to pass product info from airport to airport.
So I can either pass it at relationships or node.
I need some help here
I have created a property list in relationships which will hold the product Ids, now the question is how to search the all the relationships and filter on list for product ID
match path= (n1:Product) -[rel*..10] ->(n2)
where n1.name = "Product 1" and all(rel in relationships(path) where n1.name in rel.PID)
return path
To get the warehouse node, you need to add PID property to "RECEIVES" relationship with values PID = [1,2] for warehouse 1 and PID = [3] for warehouse 2
Thanks ameyasoft. Thats works you have been a great help.
However as you suggested , to get the warehouse node, you need to add PID property to "RECEIVES" relationship.
so my question is , is there a way to search of only a particular relationship along the path.
For eg: I just want to search for TRANSPORT relationship along the path and apply filter on them and not for the rest. Is this possible? or is there any alternate solution you can suggest, probably by using WITH clause?
Otherwise i have to attach the Product ID (PID) to every relationship even when its not required which is not ideal.
Try this with this change in line 2
where n1.name = "Product 1" and type(rel) = "TRANSPORT" and n1.name in red.PID
and comment out third line or delete
Please check this: n1.name = "Product 1" and rel.PID = 1 or 2 or 3. If you have an ID property in Product node then you should use n1.ID in rel.PID.
Please check all this and let me know.