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.

Creating nodes depending on full text search results

LJRB
Graph Buddy

Hello,

I have a a database that contains articles, topic nodes and keyword nodes.

Keyword has a relationship with topic nodes.

I would like to create a relationship between articles nodes and topics nodes.

Something like this: (:ARTICLE)-->(:TOPIC)

I would like to create this relationship only if a keyword related to a topic appears in an article with full text search.

Is it possible to apply full text search on articles nodes and next create a relation between topics and article nodes with Cypher requests ? Maybe it is better to use CONTAINS keyword instead of full search ?

4 REPLIES 4

Sure, that's no problem. You'll need a full text index of course, and the solution might look something like this:

WITH 'economy' as keyword
MATCH (t:Topic { name: keyword })
WITH t
CALL db.index.fulltext.queryNodes("articleKeywords", keyword) YIELD node, score
CREATE (node)-[:TALKS_ABOUT]->(t)

Thank you @david.allen. If I want to iterate throught several keyword with a variable can I do something like this ?

FOREACH $keyword IN TOPIC_NODE
WITH $keywork  as keyword
MATCH (t:Topic { name: $keyword  })
WITH t
CALL db.index.fulltext.queryNodes("articleKeywords", keyword) YIELD node, score
CREATE (node)-[:TALKS_ABOUT]->(t)

not that syntax, but that idea, yes. Something like this:

MATCH (t:Topic)
WITH t.name as keyword
(... rest of query here ....)

Thank you @david.allen