Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-16-2021 07:35 PM
Hi,
How do you check existence of the node if the property is type of array?
Before, I set the Product node's "vertical" property is 'string' type.
so I used like query below
match (w:Word)-[:SEARCH]->(c:Category)
with c
with collect(c)[0..5] as cs
return any(cat in cs where exists((cat)-[:INCLUDE]->(:Product {vertical: 'DEP'}))) as flag1,
any(cat in cs where exists((cat)-[:INCLUDE]->(:Product {vertical: 'OUT'}))) as flag2
but now, 'vertical' property is array type.
and this is impossible way (it's obvious)
any(cat in cs where exists((cat)-[:INCLUDE]->(:Product {'DEP' in vertical}))) as flag1,
any(cat in cs where exists((cat)-[:INCLUDE]->(:Product {'OUT' in vertical}))) as flag2
example query is the part of the whole cypher..
so I have to care about the cost of the cypher.
Please comment if you have any good idea
Thanks
Leila
Solved! Go to Solution.
11-19-2021 06:41 AM
I think that the following statement should be fine (I changed collect(c)[0..5]
with WITH c LIMIT 5
and I collected vertical
properties so that I can check only this property 😞
MATCH (w:Word)-[:SEARCH]->(c:Category)
WITH c LIMIT 5 // only 5 nodes
MATCH (c)-[:INCLUDE]->(p:Product) // match products
WITH collect(p.vertical) as verticals // collect verticals
RETURN any(vert in verticals where "DEP" in vert), any(vert in verticals where "OUT" in vert)
11-19-2021 06:41 AM
I think that the following statement should be fine (I changed collect(c)[0..5]
with WITH c LIMIT 5
and I collected vertical
properties so that I can check only this property 😞
MATCH (w:Word)-[:SEARCH]->(c:Category)
WITH c LIMIT 5 // only 5 nodes
MATCH (c)-[:INCLUDE]->(p:Product) // match products
WITH collect(p.vertical) as verticals // collect verticals
RETURN any(vert in verticals where "DEP" in vert), any(vert in verticals where "OUT" in vert)
All the sessions of the conference are now available online