Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Members / jhb / A problem with neo4j's db.schema()?

A problem with neo4j's db.schema()?

by Jörg Baach last modified Apr 26, 2018 06:52 AM
Is there a problem with db.schema showing wrong results?

UPDATE: tl;dr: db.schema() is broken, use apoc.meta.schema() instead.

I have the following sample cypher, creating some nodes and some relations:

CREATE
(footypeA:Footype {name:'FootypeA'}),
(fooA:Foo {name:'FooA'}),
(fooB:Foo {name:'FooB'}),
(bartypeA:Bartype {name:'BartypeA'}),
(bartypeB:Bartype {name:'BartypeB'}),
(barA:Bar {name:'BarA'}),
(barB:Bar {name:'BarB'}),
(fooA)-[:HAS_TYPE]->(footypeA),
(fooB)-[:HAS_TYPE]->(footypeA),
(barA)-[:HAS_TYPE]->(bartypeA),
(barB)-[:HAS_TYPE]->(bartypeB);

This gives us some nodes and relations as in the image below, in the top section:

neo4j browser results for has_type and db.schema
(click to enlarge)

But why, oh why, does the call to db.schema in the bottom section show us some ackward meta schema? Why does neo4j think that there is a "has_type" relation from a Foo to a Bartype? I mean, everybody knows that foos and bars are different things...

This is on neo4j-community-3.3.5.

[...]

UPDATE: And it turns out, this is a long known bug:

https://github.com/neo4j/neo4j/issues/9726

Workaround:

call apoc.meta.graph()

Silly me, I should have looked up the bug in the first place. Or maybe neo4j should have fixed it? Or changed their documentation?...

Add comment

You can add a comment by filling out the form below. Plain text formatting.

Question: What is 6 times 7?
Your answer: