Disclaimer: this package is still at an experimental level, and should only be used for testing, bug reports, and enhancement requests. As long as this package is in “Experimental” mode, some changes to the API are to be expected. Read the NEWS.md to be informed of the last changes.
This package has only been tested on these platforms for now, so it might not work on others :
-
neo4j 3.3.3
- Mac OSX
The goal of play4j is to facilitate Neo4J orchestration from R.
You can install {play4j} from GitHub with:
# install.packages("remotes")
remotes::install_github("ThinkR-open/play4j")
- Create an instance with
neo4j_shell$new
and the path to yourNEO4JHOME
:
cypher_con <- play4j::neo4j_shell$new("/Users/colin/neo4j/")
Verify the Neo4J shell was found by running :
cypher_con$cypher_shell
#> [1] "/Users/colin/neo4j/bin/cypher-shell"
You should get a path to the cypher shell. If the returned value is
character(0)
, please check the path you have provided.
- Start Neo4J :
# In the background
cypher_con$start()
# In the front
cypher_con$console()
- Make cypher call
You can make cypher call with the cypher method :
cypher_con$cypher(cypher = "MATCH (n) RETURN n LIMIT 5;",
username = "neo4j", password = "pouetpouet", format = "plain")
- Restart Neo4J :
cypher_con$restart()
- See logs and certificates list :
# See the last 5 lines
cypher_con$see_logs(size = 5)
#> 2018-03-09 15:22:45.212+0000 INFO Bolt enabled on 127.0.0.1:7687.
#> 2018-03-09 15:33:47.424+0000 INFO ======== Neo4j 3.3.3 ========
#> 2018-03-09 15:33:47.493+0000 INFO Starting...
#> 2018-03-09 15:33:48.229+0000 INFO Neo4j Server shutdown initiated by request
#> 2018-03-09 15:33:49.087+0000 INFO Bolt enabled on 127.0.0.1:7687.
cypher_con$see_certificates()
#> neo4j.cert
#> neo4j.key
You can also see plugins, imports, data and run.
- See status
cypher_con$status()
- Get Neo4J version
# Apparently not available on windows
cypher_con$version()
- Stop Neo4J
cypher_con$stop()
If you simply want to make API calls, start a new neo4j_api
object:
api_con <- play4j::neo4j_api$new(url = "http://localhost:7474", user = "neo4j", password = "pouetpouet")
Then query (result as JSON or as an R list):
# As JSON (default)
api_con$query("MATCH (p:Person) RETURN p.name LIMIT 1")
#> [
#> [
#> {
#> "row": [
#> ["Keanu Reeves"]
#> ],
#> "meta": [
#> {}
#> ]
#> }
#> ]
#> ]
# As R list
api_con$query("MATCH (p:Person) RETURN p.name LIMIT 1", format = "R")
#> [[1]]
#> [[1]][[1]]
#> [[1]][[1]]$row
#> [[1]][[1]]$row[[1]]
#> [1] "Keanu Reeves"
#>
#>
#> [[1]][[1]]$meta
#> [[1]][[1]]$meta[[1]]
#> NULL
You can call Neo4J admin commands by creating a new neo4j_admin object:
admin <- play4j::neo4j_admin$new("/Users/colin/neo4j/")
You can call admin commands with args that looks like shell commands
(i.e. you should type args = "--verbose true"
, for example).
admin$memrec()
Every admin method comes with a help
arg, that can be turned on to get
the list of args to pass to the commands.
admin$check_consistency(help = TRUE)
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.