neo4j-rstats / neo4r

A Modern and Flexible Neo4J Driver
https://neo4j-rstats.github.io/user-guide/
Other
106 stars 29 forks source link

get_schema delivers only a part of the schema? #22

Closed IraRe closed 5 years ago

IraRe commented 6 years ago

Follwing code snippet only delivers a part of the actual graph schema:

library(neo4r)
con <- neo4j_api$new(url = "http://52.86.4.26:34781", user = "neo4j", password = "cheaters-garages-cardboard")
con$get_schema()
#> # A tibble: 1 x 2
#>   label   property_keys
#>   <chr>   <chr>        
#> 1 Station sid

The Station nodes contain at least one more property name which is not shown in the schema? Why is it so? Is it also possible to see which relationship types exist?

ColinFay commented 6 years ago

Hi @IraRe, thanks for reaching out,

Here's the result from reproducing your code here :

capture d ecran 2018-04-22 a 14 47 18

library(neo4r)
con <- neo4j_api$new(url = "http://52.86.4.26:34781", 
                     user = "neo4j", password = "cheaters-garages-cardboard")
con$get_schema()

# A tibble: 5 x 2
  label   property_keys
  <chr>   <chr>        
1 Station sid          
2 Station name         
3 Station name         
4 Station latitude     
5 Station longitude    

Which seems to be the same as what happens when you run call db.schema() in the Neo4j browser:

There is no property in the schema, so there is no relationships in this call right now

capture d ecran 2018-04-22 a 14 51 11

If ever there was relationships in your schema, you could get them with:

con$get_relationships()
# A tibble: 1 x 1
  relationships
  <chr>        
1 TRIP

The weird thing here is that get_relationships() returns results, but not get_schema(). But this seems to be Neo4J related, as there is no relationships in the call db.schema().

I'll dig into this and let you know.

IraRe commented 6 years ago

Thank you, Colin, for your answer! That explains, why I get the property "name" twice now, as it is used twice in a simple and a compound index.

chucheria commented 5 years ago

Hi @ColinFay, sorry for opening this closed issue but I noticed this is not true anymore:

$ > ./neo4j version
neo4j 3.5.2
> library(magrittr)
> library(neo4r)
> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin17.5.0 (64-bit)
Running under: macOS  10.14.2

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] neo4r_0.1.1.9000 magrittr_1.5    

loaded via a namespace (and not attached):
 [1] igraph_1.2.3      Rcpp_1.0.0        rstudioapi_0.9.0  tidyselect_0.2.5  xtable_1.8-3      R6_2.3.0          rlang_0.3.1      
 [8] httr_1.4.0        tools_3.5.0       data.table_1.12.0 htmltools_0.3.6   digest_0.6.18     attempt_0.2.1     tibble_2.0.1     
[15] crayon_1.3.4      shiny_1.2.0       tidyr_0.8.2       purrr_0.3.0       later_0.8.0       promises_1.0.1    curl_3.3         
[22] glue_1.3.0.9000   mime_0.6          compiler_3.5.0    pillar_1.3.1      jsonlite_1.6      httpuv_1.4.5.1    pkgconfig_2.0.2  

> packageVersion("neo4r")
[1] ‘0.1.1.9000’

> con <- neo4j_api$new(
+   url = 'http://localhost:7474',
+ )
> con
<neo4j connection object>
Connected at http://localhost:7474 
User: neo4j 
Neo4j version: 3.5.2 

# The insert is the one done in the browser when you do :play movie-graph > create
# I can put it here but it is long and it is the play data 

> con$get_schema()
Null data.table (0 rows and 0 cols)

While in the browser in Neo4j, from CALL db.schema() I get:

"nodes": [
{
  "indexes": [],
  "name": "Movie",
  "constraints": []
}
,
{
  "indexes": [],
  "name": "Person",
  "constraints": []
}
]

"relationships": [
{

}
,
{

}
,
{

}
,
{

}
,
{

}
,
{

}
]

Nodes and relationships.

Next I call CREATE INDEX ON :Person(name) and...

> con$get_schema()
    label property_keys labels
1: Person          name Person

I don't know when this changed but maybe get_schema should be renamed to get_index() ❓

Thank you for reading all this!

ColinFay commented 5 years ago

Hey @chucheria,

the get_schema() is called that way because it hits the db/data/schema/index from the API (it doesn't do CALL db.schema().

But they don't return the exact same data apparently 🤔

Any input on that @dfgitn4j ?

chucheria commented 5 years ago

Hi @ColinFay ! Thanks for answering! I saw the code and that's why I didn't write before but then I tried to call CALL db.schema() from R and return an error. It would be neat to check the schema or change the get_schema to get_index so it is more clear.

Not a big problem though! We can totally work without this ;)

ColinFay commented 5 years ago

Yeah there is a bug in CALL db.schema() I haven't investigated yet #9

I'll switch to get_index, seems good to me.

Colin

ColinFay commented 5 years ago

switched to get_index :)