Azure-cosmos-dotnet-v2: cosmos graph api gremlic syntax error

Created on 11 Jan 2018  路  14Comments  路  Source: Azure/azure-cosmos-dotnet-v2

I am entirely new to graph databases and I am basically getting to grips the concepts and language by following a tutorial (sql2gremlin)

The following query returns a list of strings that are valid
g.V().has("administrator","[email protected]").values("companyName")
returns

[Widgets Inc,Widgets Inc (uk)]

According to the tutorial the following should return a list of the string lengths of the strings
g.V().has("administrator","[email protected]").values("companyName").map {it.get().length()}
but I get the following error

Gremlin Query Compilation Error: Script compile error: Unsupported groovy language rule: 'closure' text: '{it.get().length()}' @ line
1, column
80.

1 Error(s)

    ExceptionType : GraphCompileException

    Source : Microsoft.Azure.Graphs

    Context : graphclientext

    RequestId :

730d9947-fb31-4909-8ac7-240d37245420

    Scope : graphparse-translate-outer

    Status : ScriptEvaluationError

    HResult :

0x80131500

graph planned

Most helpful comment

Adding support for lambdas in CosmosDB will be more difficult due to a number of technical blockers that would need to be resolved. Consequently, extending gremlin to support string predicates (and other string functions) will be the easier path.

In addition, adding support for string functions is already planned for Q1, and we will provide more details and announcements closer to the availability date.

All 14 comments

You are making use of a groovy lambda expression {it.get().length()} on a map step which CosmosDB Graph implementation of gremlin does not support.

We have previously received feedback on supporting string predicates/functions we are currently reviewing these asks.

We don't have plans to add support for lambdas at this stage. Tinkerpop recommends avoiding lambdas where possible, and our aim is to extend gremlin to provide alternatives to using lambdas.

OK thanks. Is there some reference somewhere which would tell me what and what is not supported. I am having difficulty finding documentation and good examples of CosmosDB graph...

The Gremlin support page has details on what is supported by CosmosDB. The page does need to be improved with more details, specifically on lack of lambda and scripting support, but in the meantime we can answer questions related to this.

What are your thoughts on adding support for lambdas for now so we have something we can work with, and then gradually replace with your extension alternatives as they are released? I'm working on a project where I need to add support for querying on string values with predicates such as startsWith() or contains(), and I'd rather not do it on the entire result set after doing the gremlin query.

I understand that lambdas are not ideal from a performance/readability perspective, but I'm hoping maybe we can come to a first-make-it-work-then-make-it-nice kind of situation here. I'm also not sure how big an effort it would be to add lambda support, maybe it's comparable to that of actually implementing the gremlin extensions.

Adding support for lambdas in CosmosDB will be more difficult due to a number of technical blockers that would need to be resolved. Consequently, extending gremlin to support string predicates (and other string functions) will be the easier path.

In addition, adding support for string functions is already planned for Q1, and we will provide more details and announcements closer to the availability date.

Sounds great, looking forward to the announcement!

Are there any news on the status of string predicates? Can you disclose which functions you are adding support for?

Q1 of what year?

+1 on string predicates
We also need to perform something like below and are currently blocked;

g.V().filter({ it.getProperty("foo").contains("search") })

@olivertowers @LuisBosquez Any ETA on this?

@syedhassaanahmed As far as string predicates go, would something like this suit your needs?

@BenjaBobs This would definitely help but something like this doesn't exist today, right? :)

Correct, I too am hoping to see something like it implemented in the near future. :)

Any updates on lambdas and predicates?
We also need such functionality in order to support case insensitive search and other stuff.

How do I do a case insensitive contains()?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kspearrin picture kspearrin  路  4Comments

bowen5 picture bowen5  路  4Comments

wingfeng picture wingfeng  路  8Comments

Frankwayne picture Frankwayne  路  3Comments

brokentriangles picture brokentriangles  路  8Comments