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.

Add relations between nodes that have similar text attributes

simone
Node Link

Hello,

I have this situation:

  • a series of nodes that contains a property text with strings like:
    "California's change directly affects many of these companies, and more states are likely to soon follow"

  • then I have nodes for locations, thus I have one with id=California

I'd like to connect all nodes that contains "California" in their text with the node "California", but I am at a loss on how to handle the string search in Cypher...

Where should I look for pointers in the doc?

1 ACCEPTED SOLUTION

martin3
Node Clone

What about this one?

MATCH (n:Node)
WHERE n.text CONTAINS ’California’
MATCH (l:Location)
WHERE l.id = ’Californa’
MERGE (n)-[CONTAINS]->(l)

View solution in original post

2 REPLIES 2

martin3
Node Clone

What about this one?

MATCH (n:Node)
WHERE n.text CONTAINS ’California’
MATCH (l:Location)
WHERE l.id = ’Californa’
MERGE (n)-[CONTAINS]->(l)

Hi @simone

You can always adjust your string search according to your preferences with a regex base search. It's supported by Neo4J.

Bennu

Oh, y’all wanted a twist, ey?