cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Conditional statement with string list

mjarij
Node Link

Hi,

In my following code, it is creating Node nodes whichever link is getting BUT I want to create/merge Category nodes if the link[''] value starts with 'Category:' and Node type nodes should be created if link[''] value doesn't start with 'Category:'.

P.S. In this Wikipedia API there is JSON field named as asterisk(*) by default, so don't get confuse with it.

CALL {
MATCH (n:Node { traversed:false })
RETURN n
LIMIT 5
}
CALL apoc.load.json('https://en.wikipedia.org/w/api.php?format=json&action=parse&prop=links&page=' + apoc.text.urlencode(n.name))
YIELD value as result
UNWIND result.parse.links AS link
MERGE (cn:Node {name: link['*']})
ON CREATE SET cn.traversed = false
MERGE (n)-[:Linked]->(cn)
SET n.traversed = true
RETURN 'Total nodes get: ' + count(result)

I have tried several WHERE and FOREACH clauses but these are not working with List type. Please let me know how to do it?

Thanks,
Mustafa

1 ACCEPTED SOLUTION

Take a look at your options here:

View solution in original post

4 REPLIES 4

Take a look at your options here:

Thanks @andrew.bowman, apoc.do.when() worked for me Thanks

jggomez
Graph Voyager

Hi, You could use an APOC

CALL apoc.do.when(Predicate, SENTENCE) YIELD value

Thanks

Thanks @jggomez , it worked for me Thanks