Skip to content

Instantly share code, notes, and snippets.

@codegordi
Created June 4, 2013 13:16
Show Gist options
  • Save codegordi/5705819 to your computer and use it in GitHub Desktop.
Save codegordi/5705819 to your computer and use it in GitHub Desktop.
Connect to neo4j and send Cypher query (R on MacOS)
library('bitops')
library('RCurl')
library('RJSONIO')
query = function(querystring) {
h = basicTextGatherer()
curlPerform(url="http://<your host IP>/db/data/ext/CypherPlugin/graphdb/execute_query",
postfields=paste('query',curlEscape(querystring), sep='='),
writefunction = h$update,
verbose = FALSE
)
result <- fromJSON(h$value())
#print(result)
data <- data.frame(t(sapply(result$data, unlist)))
print(data)
names(data) <- result$columns
}
q = # example query
"
start t = node:node_index('ID:ABC0123456789')
return t.ID, t.node_prop1, t.node_prop2
"
data = query(q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment