Unable to use existing graph from Neo4j in Cypher for Apache Spark (CAPS)

(Wallerprogramm) #1

I'm currently trying to import a graph from Neo4j with CAPS to apply some cypher queries and write back to Neo4j. As far as I could see all examples first create a new graph to use later on.
Has someone here experience with that? May attempts didn't work so far. Therefore, it would be really helpful to have some example code to see how it works with an existing Neo4j graph.

Below is some code that I already tried.

import org.opencypher.spark.api._
import org.opencypher.okapi.api.graph._
import org.opencypher.okapi.neo4j.io.Neo4jConfig
import java.net.URI

object MultiInput {

  def main(args: Array[String]): Unit = {
    // Create CAPS session
    implicit val session: CAPSSession = CAPSSession.local() //create(spark)

   // Here I needed to add the Option("pw") inorder to not have an error
    val neo4jConfig = Neo4jConfig(URI.create("bolt://localhost:7687"), "neo4j", Option("blob"), false)

    // Access the graphs via their qualified graph names
    //val txGraph = session.catalog.graph("txGraph.graph")
    //session.catalog.register(Namespace("txGraph"), GraphSources.cypher.neo4j(neo4jConfig))
    session.registerSource(Namespace("txGraph"), GraphSources.cypher.neo4j(neo4jConfig))

    val txGraph = session.catalog.graph("txGraph.graph")

    // Test graph access
    // 5) Execute Cypher query and print results
    val result = txGraph.cypher(
      """|MATCH (t:Transaction)
         |RETURN t.txid
         |LIMIT 20