How to write like queries using gremlin for Neptun

2019-08-06 09:43发布

Is there any way to write like queries Like '%match%' in gremlin without using the lambda functions?.

Neptune does not support Lambda functions

1条回答
贪生不怕死
2楼-- · 2019-08-06 10:25

There are usually ways to express lambdas with Gremlin steps. Indeed, it is often better to do so because graph providers can't optimize the portions of your queries that contain lambdas (as it is just arbitrary code).

Typically, the nature of the lambda contents determines whether or not it can be expressed easily with Gremlin steps. If the lambda uses a third-party library (e.g. a JDBC driver) that abstracts a bunch of complex or custom behavior then expressing such concepts are usually not possible with just Gremlin steps.

For string comparisons like %match% TinkerPop has long left that sort of support to the graph providers (e.g. DSE Graph full text search API). Each has its own way of expressing text searches and you would use those provider specific APIs in your applications.

As you have found, Neptune does not have such constructs at this time so there is little recourse for that capability. If you really need that feature, I'm afraid that you will have to be satisfied with a startsWith type of query:

gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V().has('name',between('m','mz'))
==>v[1]

or choose a different graph system. Note that there has been recent discussion in the community for making text based search a first-class feature of the Gremlin language, but no decision has really been made at this point.

查看更多
登录 后发表回答