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.

How to Integrate nodes by name, in neo4j?

Hi, these days i'm going to make a app which integrate NLP and recommendation enable with neo4j.

For example,
If there is a information about 'sushi' and the user say about sushi,
the 'sushi node' must be one (not two of node).
I'll show you below

But when I made a two graph,
one for user sentence and one for product there is problem that the node aren't integrated as one.

like this,

I also use MERGE statement and Double label (e.g CREATE (sushi:Cuisine:test_word_1))
but it wasn't useful at all.

so I want to ask how to integrate if the node represented 'name' is same.

I'll attach my cypher query

Graph 1

CREATE (philip:Person {name:"philip"})-[:IS_FRIEND_OF]->(emil:Person {name:"emil"}),
       (philip)-[:IS_FRIEND_OF]->(michael:Person {name:"michael"}),
       (philip)-[:IS_FRIEND_OF]->(andreas:Person {name:"andreas"})
CREATE (sushi:Cuisine {name:"sushi"}), (nyc:City {name:"new york"}),
       (isushi:Restaurant {name:"isushi"})-[:SERVES]->(sushi),(isushi)-[:LOCATED_IN]->(nyc),
       (michael)-[:LIKES]->(isushi),
       (andreas)-[:LIKES]->(isushi),
       (zam:restaurant {name:"zushi zam"})-[:SERVES]->(sushi),(zam)-[:LOCATED_IN]->(nyc),
       (andreas)-[:LIKES]->(zam) 

Graph 2 (User mentioned Graph)

WITH split("''' + last_user_message +'''"," ") AS text
                    UNWIND range(0, size(text)-2) AS i 
                    MERGE (w1:test_word_1{name: text[i]}) 
                    MERGE (w2:test_word_1{name: text[i+1]})
                    MERGE (w1)-[:NEXT]->(w2)

Any Comments would be appriciated.

Regards,

Sujeong

1 REPLY 1

intouch_vivek
Graph Steward

Hi @gjtnwjd40,

Try merge refactor like below

MATCH (sushi:Cuisine)
WITH sushi.name as cusinieName, collect(sushi) as nodes
CALL apoc.refactor.mergeNodes(nodes, {properties: "combine"}) YIELD node
RETURN node