Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

getOrCreate / getUniqueNode multiple labels #75

Open
ch-ricardor opened this issue Apr 23, 2018 · 0 comments
Open

getOrCreate / getUniqueNode multiple labels #75

ch-ricardor opened this issue Apr 23, 2018 · 0 comments

Comments

@ch-ricardor
Copy link

ch-ricardor commented Apr 23, 2018

Following one of your examples I tried to create a retweet with two labels, due the retweet is a copy of a tweet I want to have it in two different "categories".
https://nicolewhite.github.io/2014/05/30/demo-of-rneo4j-part1.html

I tested manually the use of multiple labels following:
https://neo4j.com/developer/kb/how-do-i-report-on-nodes-with-multiple-labels/

Then I tried to replicate the same functionality in R.

createNode has the possibility to create multiple labels:
createNode(theGraph,c("Tweet","ReTweet"), ...)

Is it valid getOrCreateNode(theGraph,c("Tweet","ReTweet"), ...)
and
getUniqueNode(graph, c("Tweet","ReTweet"), name = "Alice") ?

Maybe "I'm confused!" and I have to use two different statements for each label to create the nodes, but which would be the best option to retrieve unique nodes with multiple labels?

In the code I have something like:

  addConstraint(twGraph, "Tweet", "id")
  addConstraint(twGraph, "ReTweet", "id")

  getOrCreateNode(theGraph,c("Tweet","ReTweet"), ...) 

I checked the code on getOrCreate and calls

  node = try(createNode(graph, .label, ...), TRUE)

createNode has the possibility to create multiple labels:

  createNode.graph = function(graph, .label = character(), ...) {
    query = "CREATE (n"
      **if(length(.label) > 0) {
      for(i in 1:length(.label)) {
        query = paste0(query, ":", .label[i])
      }**
    }

but the call failed in getOrCreateNode:

  getOrCreateNode.graph = function(graph, .label, ...) {
    **if(!(names(props)[[1]] %in% getConstraint(graph, .label)$property_keys)) {
      stop("The first key = value pair listed in ... must be uniquely constrained for the given node label.")
    }**

"I'm confused!"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant