Hi
consider the following query which returns 2 different paths (Starting with Catalog:catalog-1
to SalesCategory:scat-o
) as expected
MATCH (c:Catalog { catalog_id: "catalog-1" }),(s:SalesCategory { sales_category_id: "scat-o" }), p = allShortestPaths((c)-[:HAS_CATEGORY|:HAS_SUBCATEGORY*]-(s))
RETURN DISTINCT p
now, we want to add some extra logic to filter the returned paths: nodes of the returned paths should not have any relation with some other nodes (we call it HideInStore nodes), here's the query:
MATCH (c:Catalog { catalog_id: "catalog-1" }),(s:SalesCategory { sales_category_id: "scat-o" }), p = allShortestPaths((c)-[:HAS_CATEGORY|:HAS_SUBCATEGORY*]-(s))
WITH c,s,p, ["his1","his99"] as his_values
OPTIONAL MATCH(h:HideInStore) where h.hide_in_store_id in his_values
WITH c,s,p,h
WHERE NONE (x in nodes (p) where ((x:SalesCategory)-[:HAS_CATEGORY_HIDE_IN_STORE]->(h)) )
RETURN DISTINCT p
here's the case: query works fine if it can find at least one path to return. but when there's no path to return, it will return all avaiable paths. so
- it will return all paths, if it cannot find any node in any of the paths related to HideInStore entities (as expected)
- it will return expected path if it can find atleast one path to return (as expected)
- it will return all paths (instead of none) if there's no path to return (not expected)
I'd appreciate your review on my query. thanks.