Is there a document about how gremlin 'match()' works?

ⅰ亾dé卋堺 提交于 2020-01-14 22:49:21

问题


I'm writing gremlin query with 'match()' traversal. It seems some pattern matching behaves differently than other pattern languages.

  1. How input traverser values are bound by pattern variables.
g.V('A', 'B').match(__.as('x'), __.as('y')).project('x', 'y')
==>[x:v[A],y:v[A]]
==>[x:v[B],y:v[B]]

I think pattern variable x and y have no constraints and result will be

==>[x:v[A],y:v[A]]
==>[x:v[A],y:v[B]]
==>[x:v[B],y:v[A]]
==>[x:v[B],y:v[B]]

It seems a constraint x = y is added implicitly.

  1. When pattern variables are bound to values not listed in input traverser.

Sometimes, pattern variable are bound to values not listed in input:

g.V('A', 'B').match(__.as('x').out().as('y'), __.as('y'))
==>[x:v[A],y:v[B]]
==>[x:v[B],y:v[C]]
==>[x:v[B],y:v[D]]

In this query, we have more constraints than previous query. So, less results are expected, but results increase by capturing vertices not in input traversers.

Is there a clear documentation when pattern variables can capture such vertices.

  1. "The provided match pattern is unsolvable"

Similar query:

g.V('A', 'B').match(__.as('x').out().as('y'), __.as('z'))
The provided match pattern is unsolvable: [[MatchStartStep(z), MatchEndStep], [MatchStartStep(x), VertexStep(OUT,vertex), MatchEndStep(y)]]
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.IllegalStateException: The provided match pattern is unsolvable: [[MatchStartStep(z), MatchEndStep], [MatchStartStep(x), VertexStep(OUT,vertex), MatchEndStep(y)]]
    at org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchStep$MatchAlgorithm.lambda$static$0(MatchStep.java:690)
    at org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchStep$CountMatchAlgorithm.apply(MatchStep.java:757)
    at org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchStep$CountMatchAlgorithm.apply(MatchStep.java:723)
    at org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchStep.standardAlgorithm(MatchStep.java:398)

This has less constraints than previous one. What this error means.

来源:https://stackoverflow.com/questions/55609832/is-there-a-document-about-how-gremlin-match-works

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!