Home > Blockchain >  How to find the pointer node of a relationship using full text search on the edge node in neo4j
How to find the pointer node of a relationship using full text search on the edge node in neo4j

Time:10-27

This question is related to Neo4j databases. Suppose I have a relationship (employee)-[WORKS-IN]->(company).. Imagine an employee works in multiple companies. I should be able to find the companies that a specific employee is working using full text search in neo4j. I'll be searching from the users name and I should be able to return company nodes..how to do that??

Full text search must be used.

CodePudding user response:

So you want to search for a Person by name with full text and then retrieve the companies he worked for.

Compare this easily with the default Movies graph in Neo4j, you want to search for a Person by name with full text and then retrieve the movies the person acted in .

CALL db.index.fulltext.queryNodes('Person', 'kea*')
YIELD node
MATCH (node)-[:ACTED_IN]->(movie)
RETURN node.name, movie.title

CodePudding user response:

This is an example when I created this node:

CREATE (e:Employee {name: 'Nirmana Testing'}) 

Then create the full text index on Employee.name

CREATE FULLTEXT INDEX employeeNameIdx FOR (e:Employee) ON EACH [e.name]

Then run a query using this full text index. Noted that the keyword 'nirmana' can be upper case or any case.

CALL db.index.fulltext.queryNodes("employeeNameIdx", "nirmana") YIELD node as employee
MATCH (employee)-[:WORKS-IN]->(company:Company)
RETURN employee, company

reference: enter image description here

  • Related