0
votes

I am currently doing a research project and I've built 2 ontologies of 2 domains using Neo4j graph database. Now there's a requirement for me to construct sentences using the nodes and relationships separately for the two domains for a string matching purpose. For example, if the nodes and relationship are as follows:

(n:Person{name:'John'})-[r:knows]->(m:Person{name:'Smith'})

I want to get the sentence "John knows Smith". Also, another important thing is in the ontologies there are different types of relationships. So I want to get the sentences without worrying about the relationship types. For example, if we take the above example I should be able to get the result without having to use the relationship type "knows" anywhere, simply by using a generic way.

I have built the ontologies on the same sandbox by giving "Finance" and "Politics" as node labels to differentiate them. I've given a property to each node as "name" and it states the word of the domain. For example, if there's a word in the financial domain as 'profit' the create query would be like CREATE(n:Finance{name:'profit'}). I want to get the name of the nodes and make the sentence.

Is there a suitable Neo4j query to do so or is there a way to accomplish this by using a Spring Boot backend API. I've already constructed a Spring Boot API to do some basic functionalities like adding nodes and relationships. What I'm asking is, is there a direct query to build sentences from nodes and relationships or is there a way to do so by using Java Spring Boot? But it would be great if anyone can suggest a neo4j query to accomplish this.

1
Please do not ask in the comments for urgent assistance; all questions are of equal priority here. Please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions.halfer

1 Answers

1
votes

I if understand your question, you can use type() function.

match (a)-[r]->(b)
return a.name + " " + type(r) + " " + b.name