graphaware / neo4j-uuid

GraphAware Runtime Module that assigns a UUID to all nodes (and relationships) in the graph transparently
103 stars 22 forks source link

Can't seem to initialize correctly #13

Closed amosjyng closed 8 years ago

amosjyng commented 8 years ago

Hi,

I'm trying to use this in Embedded Mode, and am running into difficulties.

The GraphAwareRuntime seems to get successfully started, as this runs without problems:

RuntimeRegistry.getRuntime(this.neo4jdb).waitUntilStarted();

But then this assertion fails:

try (Transaction tx = this.neo4jdb.beginTx())
{
    assert this.neo4jdb.index().existsForNodes("uuidIndex");
}

and of course the created nodes have no uuid property.

My neo4j.properties contains

com.graphaware.runtime.enabled=true
com.graphaware.module.UIDM.1=com.graphaware.module.uuid.UuidBootstrapper
com.graphaware.module.UIDM.uuidProperty=uuid
com.graphaware.module.UIDM.uuidIndex=nodeIndex

Any ideas what I might be doing wrong?

Thanks!

bachmanm commented 8 years ago

Could you post the entire piece of the code where you're creating your GraphDatabaseService? If you're using the properties approach, it needs to look something like:

 GraphDatabaseService database = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(pathToDb)
    .loadPropertiesFromFile(this.getClass().getClassLoader().getResource("neo4j.properties").getPath())
    .newGraphDatabase();
amosjyng commented 8 years ago

Thanks, this is my initialization code:

String neo4jSettingsPath = Database.class.getClassLoader().getResource("neo4j.properties").getPath();
this.neo4jdb = new GraphDatabaseFactory()
        .newEmbeddedDatabaseBuilder(new File("test.db"))
        .loadPropertiesFromFile(neo4jSettingsPath)
        .newGraphDatabase();

RuntimeRegistry.getRuntime(this.neo4jdb).waitUntilStarted();

try (Transaction tx = this.neo4jdb.beginTx())
{
    assert this.neo4jdb.index().existsForNodes("uuidIndex");
}
bachmanm commented 8 years ago

ok, second pair of eyes didn't help, so I had to debug through this only to find out you're asserting the wrong thing :)

So, either change your config to

com.graphaware.module.UIDM.uuidIndex=uuidIndex

or your test to

assert this.neo4jdb.index().existsForNodes("nodeIndex");
amosjyng commented 8 years ago

D'OH! Hahahaha, thanks!

Though... I still can't seem to get the assertion to pass, and no indices seem to be created either. I've created a small program that produces the problem I'm seeing, would you be willing to take a look at that? I'm sure it's something stupid again, just can't figure out what it is. Sorry for the trouble.

bachmanm commented 8 years ago

Two problems with your app: 1) you need to create a node first that is indexed, in order to see the index 2) you're asserting a schema index, but this module uses legacy indexes. The reason for that is that schema indexes are tied to labels, but we want to create the index no matter what labels your node has, even if it has none.

bachmanm commented 8 years ago

I issued a pull request to your repo that demonstrates what I just said

amosjyng commented 8 years ago

I see, that works, thank you so much! :)