opencypher / cypher-for-gremlin

Cypher for Gremlin adds Cypher support to any Gremlin graph database.
Apache License 2.0
356 stars 48 forks source link

latest cypher-gremlin-extensions not worked according to docs guide #326

Closed bangsun closed 4 years ago

bangsun commented 4 years ago

In v0.9.12 cypher-gremlin-extensions works well,I can use toInteger function well, but when upgrade to v1.0.3(janusgraph 0.4.0) and config according to docs, it fails. Steps:

gremlin> :plugin list
==>opencypher.gremlin[active]
gremlin> :remote connect opencypher.gremlin conf/remote-objects.yaml translate gremlin+cfog_server_extensions
gremlin> :> explain match (n:person)-[r3:person_clmno]->(c:clmno{conttype:'1'}) where c.accdate>='2016-08-01' and (toInteger(substring(c.accdate,0,4))-toInteger(substring(n.personbirthday,0,4)))>16 return n;
org.opencypher.gremlin.translation.exception.SyntaxException: Custom functions and predicates are not supported on target implementation: cypherSubstring, cypherToInteger. Consider installing Extensions to Gremlin to enable full support for Cypher functionality: https://github.com/opencypher/cypher-for-gremlin/tree/master/tinkerpop/cypher-gremlin-extensions
Type ':help' or ':h' for help.
Display stack trace? [yN]

and the gremlin-server.yaml:

scriptEngines: {
  gremlin-groovy: {
    staticImports: ['org.opencypher.gremlin.process.traversal.CustomPredicates.*','org.opencypher.gremlin.process.traversal.CustomFunctions.*']

when check the class above ,I found the 'process' not exist,so the right classpath is org.opencypher.gremlin.traversal.CustomPredicates.*,org.opencypher.gremlin.traversal.CustomFunctions.* ? but failed again when correct that way. so I wonder anything wrong or miss conf?

bangsun commented 4 years ago

in addtion , the CypherOpProcessor already config as below: - { className: org.opencypher.gremlin.server.op.cypher.CypherOpProcessor, config: { cacheExpirationTime: 600000, cacheMaxSize: 1000 }}

bangsun commented 4 years ago

After survery, it may caused by explain can't use when connect as

gremlin> :remote connect opencypher.gremlin conf/remote-objects.yaml translate gremlin+cfog_server_extensions
gremlin> :> explain match(n) return substring(n.value,0,2) limit 1;
org.opencypher.gremlin.translation.exception.SyntaxException: Custom functions and predicates are not supported on target implementation: cypherSubstring. Consider installing Extensions to Gremlin to enable full support for Cypher functionality: https://github.com/opencypher/cypher-for-gremlin/tree/master/tinkerpop/cypher-gremlin-extensions

when using below it works:

gremlin> :remote connect opencypher.gremlin conf/remote-objects.yaml
gremlin> :> explain match(n) return substring(n.value,0,2) limit 1;
==>[translation:g.V().project('substring(n.value,0,2)').by(__.project('  GENERATED1', '  GENERATED2', '  GENERATED3').by(__.choose(neq('  cypher.null'), __.choose(__.values('value'), __.values('value'), __.constant('  cypher.null')))).by(__.constant(0)).by(__.constant(2)).select(values).map(cypherSubstring())).limit(1),options:[EXPLAIN]]
dwitry commented 4 years ago

Hello @bangsun,

According to description it looks like plugin versions in console and server does not match.

Please clarify which version of console plugin are you using? (ls ext/cypher-gremlin-console-plugin/lib/cypher-gremlin-console-plugin-*.jar from console root directory)

bangsun commented 4 years ago

@dwitry

ls ext/cypher-gremlin-console-plugin/lib/cypher-gremlin-console-plugin-*.jar
ext/cypher-gremlin-console-plugin/lib/cypher-gremlin-console-plugin-1.0.3.jar
bangsun commented 4 years ago

I've test a successful result,with following key conf point: 1.staticImports: ['org.opencypher.gremlin.traversal.CustomPredicates.*','org.opencypher.gremlin.traversal.CustomFunctions.*'], 2.org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math,org.opencypher.gremlin.traversal.CustomFunctions,org.opencypher.gremlin.traversal.CustomPredicate], methodImports: [java.lang.Math#*,org.opencypher.gremlin.traversal.CustomFunctions#*,org.opencypher.gremlin.traversal.CustomPredicate#*]}, 3.- { className: org.opencypher.gremlin.server.op.cypher.CypherOpProcessor } but the second point may miss in the docs.

dwitry commented 4 years ago

Hello @bangsun,

thank you very much for pointing out gap in the documentation. I've updated it (#333)