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.

Extract subgraph using neo4j with spark

Hi,
I did install the community edition with the neo4j spark connector on a server and it is running fine. I am new to spark and I am trying to extract subgraph out of the original graph that I uploaded to neo4j. I get lost in all the options of RDD, DataFrame, GraphX, and GraphFrame. I am not sure what I should use.
I have a list of interactions for example Match (n:Student{name:Sara}) -[r]-(m:Teacher{name:John})
I am trying to extract these interactions and do some processing on the resulted subgraph(s) like find the teachers who exist in one subgraph but not in the other one (each subgraph will be created from a separate list of connections). I tried dataFram and I got an error when I have an empty record and I solved it by adding Set.empty and now I have another problem. here is my code:

val List1: List[String] = List("Sam","Sara","Kevin","Smith")
var rddDataFrame1 = Neo4jDataFrame.withDataType(sqlContext,"MATCH (n:students{name:'"+List1(0)+"'})-[r]-(m:teachers) RETURN n.name as studentName, n.school as schoolName, type(r) as relType, m.name as TeacherName, m.school as teacherSchool",Seq.empty)
for (i <- 1 until List1.length)
{
	rddDataFrame1 = rddDataFrame1.union(Neo4jDataFrame.withDataType(sqlContext,"MATCH (n:students{name:'"+List1(i)+"'})-[r]-(m:teachers) RETURN n.name as studentName, n.school as schoolName, type(r) as relType, m.name as TeacherName, m.school as teacherSchool",Seq.empty))	
}
 rddDataFrame1.show()

It shows an empty table and when I run

rddDataFrame1.count
//It returns :
Long=5

I am not sure if DataFrame is the right choice or I have to use something else.
Thanks!

1 REPLY 1

In case someone has the same problem, I solved the problem by using neo.cypher("My cypher query").loadDataFrame.