How to fire match query in gremlin . Filter query not working in cosmos db with java driver

老子叫甜甜 提交于 2019-12-02 20:40:06

问题


I have 2 problem statements with similar approach .Can I put a contains or like query in both to solve my problem in gremlin:

1) Returning vertex 'a' in the following query when the outE() (as depicted in below gremlin query) has label with contains print.

g.V().hasLabel('url').has('name','sw10707').as('a').outE('print').has('forward','states').inV().select('a')

2) Returning all the vertices as stated below which contains print in their edge labels:

g.V().hasLabel('url').has('name','sw10707').as('a').outE('print').has('forward','states').inV()

This query is not working: g.V().hasLabel('url').has('name','sw10707').as('a').outE().filter(it.name.matches('.pri.'))

An issue is already open with .net driver ( but I am not able to find similar functionality with java) : https://github.com/Azure/azure-cosmosdb-dotnet/issues/473


回答1:


This traversal:

g.V().hasLabel('url').
  has('name','sw10707').as('a').
  outE().filter(it.name.matches('.pri.'))

requires a lambda expression in filter() and should be written as a Groovy closure:

g.V().hasLabel('url').
  has('name','sw10707').
  outE().filter{it.name.matches('.pri.')}

Unfortunately, CosmosDB does not support lambdas so your traversal will fail. At this time, there isn't a workaround that I know of short of returning the edges to filter them on the client and then using them to start a second traversal...not great. Hopefully the issue you raised will bring some relief soon.

Note that I commented on that issue to mention that TinkerPop is considering making those text predicates available - the discussion is here.



来源:https://stackoverflow.com/questions/52363737/how-to-fire-match-query-in-gremlin-filter-query-not-working-in-cosmos-db-with

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