neo4j-contrib / neo4j-elasticsearch

Neo4j ElasticSearch Integration
Apache License 2.0
210 stars 79 forks source link

(Re)indexing tool #7

Open jazzido opened 9 years ago

jazzido commented 9 years ago

Implement a shell extension to force a reindex of the IndexSpecs defined in neo4j.properties as a shell extension, just like neo4j-shell-tools.

If elasticsearch_index.spec is defined as people:Person(first_name,last_name), places:Place(name), the tool would perform two queries which result will be in turn sent to ElasticSearch:

jazzido commented 9 years ago

Hi @jexp,

Is there any documentation on how to implement a shell command? I've inherited my class from AbstractApp —just like in neo4j-shell-tools— but can't get Neo4j to recognize my command:

org.neo4j.shell.ShellException: Unknown command 'elasticsearch-index'
    at org.neo4j.shell.AppCommandParser.parseApp(AppCommandParser.java:122)
    at org.neo4j.shell.AppCommandParser.parse(AppCommandParser.java:98)
    at org.neo4j.shell.AppCommandParser.<init>(AppCommandParser.java:63)
    at org.neo4j.shell.impl.AbstractAppServer.interpretLine(AbstractAppServer.java:116)
    at org.neo4j.shell.kernel.GraphDatabaseShellServer.interpretLine(GraphDatabaseShellServer.java:93)
    at org.neo4j.shell.impl.AbstractClient.evaluate(AbstractClient.java:149)
    at org.neo4j.shell.impl.AbstractClient.evaluate(AbstractClient.java:133)
    at org.neo4j.elasticsearch.ElasticSearchImportAppTest.testImportCommand(ElasticSearchImportAppTest.java:66)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)\
jexp commented 9 years ago

You missed to add the service loader for shell apps in src/main/resources

see: https://github.com/jexp/neo4j-shell-tools/blob/2.2/src/main/resources/META-INF/services/org.neo4j.shell.App

jazzido commented 9 years ago

Perfect, thanks.

jazzido commented 9 years ago

Just for the record, this has been implemented in PR #8, from my fork of neo4j-elasticsearch