gremlin-AWS Neptune 文本谓词

gremlin- AWS Neptune text predicates

gremlin> g.V().filter{it.get().property('state').value() == 'A*'}

我正在使用 AWS Neptune GraphDB。我需要获取状态名称以 'A' 开头的顶点。你能帮我解决这些文本谓词吗,它适用于 AWS Neptune gremlin。

{ TextConatinsPrefix(), TextPrefix(), Text.contains(), .matches(), .contains(), .startWith() 这些在任何组合中都不起作用}

这可能取决于 Neptune 允许的内容,但这里有一些摘自我的书中的示例,如果 Neptune 允许这些类型的 Lambda,这些示例将起作用。

g.V().hasLabel('airport').
      filter{it.get().property('desc').value().contains('Dallas')}

// Using a filter to search using a regular expression
g.V().has('airport','type','airport').
      filter{it.get().property('city').
        value ==~/Dallas|Austin/}.values('code')

// A regular expression to find any airport with a city 
//name that begins with "Dal"

g.V().has('airport','type','airport').
    filter{it.get().property('city').value()==~/^Dal\w*/}.values('city')

如果您只需要 startsWith 的行为,则可以避免使用 Lambda:

g.V().hasLabel('airport').
      has('city',between('Dal','Dam')).
      values('city')

为了完整起见,这里有一个 URL 本书和相关 material(所有开源)https://github.com/krlawrence/graph

干杯 开尔文

谢谢开尔文。 我得到了这个答案,它与 AWS-Neptune GDB

一起工作得很好
gremlin> g.V().values('state').filter{(''+it).startsWith('A')}

我们可以使用一些类似于文本谓词的java方法代替startsWith()。

添加另一个答案,现在是 2019 年,指出在 Apache TinkerPop 3.4 中引入了新的文本谓词。这些包括 startingWith()、endingWith() 和 containing() 以及它们的反函数 notStartingWith() 等。任何支持 Apache TinkerPop 3.4 或更高级别的图形数据库(包括 Amazon Neptune)都应该提供这些谓词。

希望这能帮助人们今天找到这个问题,因为原始问题是 2018 年提出的。

干杯 开尔文