Tinkerpop 查询语言上的字符串函数

String functions on Tinkerpop Query Language

查看 Tinkerpop doc,我可以找到字符串函数列表:

TextP.startingWith(string) - Does the incoming String start with the provided String?

TextP.endingWith(string) - Does the incoming String end with the provided String? 

TextP.containing(string) - Does the incoming String contain the provided String?

TextP.notStartingWith(string) - Does the incoming String not start with the provided String?

TextP.notEndingWith(string) - Does the incoming String not end with the provided String?

TextP.notContaining(string) - Does the incoming String not contain the provided String?

但是,我找不到使用它们的方法。我也尝试在 http://tinkerpop.apache.org/javadocs/current/core/org/apache/tinkerpop/gremlin/process/traversal/TextP.html 中查看有关 TextP 的 Javadoc,但在那里也找不到任何有用的信息。

像下面这样的查询过滤器工作正常:

g.V().has( label, within( 'cake', 'coffee' ) ).limit(3)

一些我测试过但没有用的查询示例:

g.V().label().startingWith('c')
g.V().label().fold().startingWith('c')
g.V().label().fold().has(__.startingWith('c'))
g.V().has(label, startingWith('c'))
g.V().has(label, TextP.startingWith('c'))
g.V().has(label.startingWith('c'))

TextP 与任何其他 Predicate 一样工作,您列出的一些用法是正确的:

gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V().has(label, startingWith("p")).label()
==>person
==>person
==>person
==>person
gremlin> g.V().has('name', endingWith("o")).values('name')
==>marko

作为旁注,我有点惊讶地发现文档中没有示例 - 我打算添加一些示例。

考虑到 AWS Neptune 上 Gremlin 的当前限制,我能找到的最佳方法是:

g.V().has(label, between("c","cz"))

这也适用于任何特定的前缀:

g.V().has(label, between("foo","fooz"))