The query below is a modified version of a query I made that works when I am searching in the CONTAINS clause for only a single product type, but I've tried multiple ways of searching for more than one, such as making a list with commas, or using the OR operator, but I can't get it to work. Any advise?
Cypher that is having issues:
MATCH (type:ProductType)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
WHERE type.name CONTAINS ("SuperU", "UAN", "Urea")
RETURN type.name AS ProductType, Q.quantity AS Quantity
And it doesn't work when I do this either:
''
WHERE type.name CONTAINS ("SuperU" OR "UAN" OR "Urea")
''
Works when I do this:
MATCH (type:ProductType)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
WHERE type.name CONTAINS "SuperU" //work with a single string but not multiple
RETURN type.name AS ProductType, Q.quantity AS Quantity
Any other advise in optimizing this query would be greatly appreciated as well.
Try the following, it uses the list predicate 'any' to achieve what you want:
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, Q.quantity AS Quantity
It would seem that you may have multiple paths for each product name, so do you want to sum the quantity per product name.
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, sum(Q.quantity) AS TotalQuantity
Try the following, it uses the list predicate 'any' to achieve what you want:
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, Q.quantity AS Quantity
It would seem that you may have multiple paths for each product name, so do you want to sum the quantity per product name.
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, sum(Q.quantity) AS TotalQuantity
Try the following, it uses the list predicate 'any' to achieve what you want:
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, Q.quantity AS Quantity
It would seem that you may have multiple paths for each product name, so do you want to sum the quantity per product name.
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, sum(Q.quantity) AS TotalQuantity
Try the following, it uses the list predicate 'any' to achieve what you want:
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, Q.quantity AS Quantity
It would seem that you may have multiple paths for each product name, so do you want to sum the quantity per product name.
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, sum(Q.quantity) AS TotalQuantity
Try the following, it uses the list predicate 'any' to achieve what you want:
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, Q.quantity AS Quantity
It would seem that you may have multiple paths for each product name, so do you want to sum the quantity per product name.
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, sum(Q.quantity) AS TotalQuantity
Try the following, it uses the list predicate 'any' to achieve what you want:
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, Q.quantity AS Quantity
It would seem that you may have multiple paths for each product name, so do you want to sum the quantity per product name.
WITH ["SuperU", "UAN", "Urea"] as types
MATCH (type:ProductType)
WHERE any (i in types where i = type.name )
MATCH (type)<-[:HAS_PRODUCT_TYPE]-(:Product)<-[:HAS_PRODUCT]-(:ProductOrigin)<-[:HAS_PRODUCT_ORIGIN]-(c:OrderLine)-[hq:HAS_QUANTITY]->(Q:Quantity)
RETURN type.name AS ProductType, sum(Q.quantity) AS TotalQuantity