Когда я обновил свою схему графа janus, я создал ключ свойства, но забыл построить индекс. Если я запускаю тот же фрагмент кода с этим buildIndex этого свойства, тогда мои данные получат избыточные данные. Поэтому я пытаюсь построить индекс прямо в консоли gremlin. Я попробовал
:remote connect tinkerpop.server conf/remote.yaml
// myScript = new File('/tmp/scripts/dbscripts/campaignTypeSchema/01_campaignTypeSchema.groovy').getText('UTF-8')
// :> @myScript
:> m = graph.openManagement()
/** Getting Vertex Labels **/
:> Campaign = m.getVertexLabel('Campaign')
/** Vertex Properties creation **/
:> campaignType = graph.openManagement().getPropertyKey('campaignType')
/** Vertex supporting indexes **/
:> graph.openManagement().buildIndex('campaignTypeByCampaign', Vertex.class).addKey(graph.openManagement().getPropertyKey('campaignType')).buildCompositeIndex()
println "Finished updating schema"
:remote close
:x
Но endedup с ошибкой
Error in /tmp/scripts/dbscripts/campaignTypeSchema/run.groovy at [9: :> Campaign = m.getVertexLabel('Campaign')] - No such property: m for class: Script36
org.apache.tinkerpop.gremlin.jsr223.console.RemoteException: No such property: m for class: Script36
at org.apache.tinkerpop.gremlin.console.jsr223.DriverRemoteAcceptor.submit(DriverRemoteAcceptor.java:178)
at org.apache.tinkerpop.gremlin.console.commands.SubmitCommand.execute(SubmitCommand.groovy:41)
at org.codehaus.groovy.tools.shell.Shell.execute(Shell.groovy:104)
at org.codehaus.groovy.tools.shell.Groovysh.super$2$execute(Groovysh.groovy)
at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
at org.codehaus.groovy.tools.shell.Groovysh.executeCommand(Groovysh.groovy:273)
at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:164)
at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.super$3$execute(GremlinGroovysh.groovy)
at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:145)
at org.apache.tinkerpop.gremlin.console.GremlinGroovysh.execute(GremlinGroovysh.groovy:72)
at org.apache.tinkerpop.gremlin.console.Console$_executeInShell_closure16.doCall(Console.groovy:371)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at groovy.lang.Closure.call(Closure.java:418)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.eachWithIndex(DefaultGroovyMethods.java:2041)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.eachWithIndex(DefaultGroovyMethods.java:2021)
at org.codehaus.groovy.runtime.DefaultGroovyMethods.eachWithIndex(DefaultGroovyMethods.java:2071)
at org.codehaus.groovy.runtime.dgm$175.doMethodInvoke(Unknown Source)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
at org.apache.tinkerpop.gremlin.console.Console.executeInShell(Console.groovy:348)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
at org.apache.tinkerpop.gremlin.console.Console.<init>(Console.groovy:141)
at org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:236)
at org.apache.tinkerpop.gremlin.console.Console.main(Console.groovy:453)
Затем я попытался запустить непосредственно в консоли gremlin
gremlin> :> graph.openManagement().buildIndex('campaignTypeByCampaign', Vertex.class).addKey(graph.openManagement().getPropertyKey('campaignType')).buildCompositeIndex()
Для этого я получил ошибка, говорящая
The vertex or type is not associated with this transaction [campaignType]