neo4j-elasticsearch icon indicating copy to clipboard operation
neo4j-elasticsearch copied to clipboard

(Re)indexing tool

Open jazzido opened this issue 10 years ago • 4 comments

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:

  • MATCH (n:Person) RETURN n.first_name, n.last_name sent to index people
  • MATCH (n:Place) RETURN n.name sent to index places.

jazzido avatar May 20 '15 18:05 jazzido

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)\
  • Failing test: https://github.com/jazzido/neo4j-elasticsearch/blob/shell-command/src/test/java/org/neo4j/elasticsearch/ElasticSearchImportAppTest.java
  • Shell command class: https://github.com/jazzido/neo4j-elasticsearch/blob/shell-command/src/main/java/org/neo4j/elasticsearch/ElasticSearchImportApp.java

jazzido avatar May 25 '15 04:05 jazzido

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

jexp avatar May 25 '15 18:05 jexp

Perfect, thanks.

jazzido avatar May 25 '15 18:05 jazzido

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

jazzido avatar Jun 24 '15 23:06 jazzido