No vertex properties in json returned by gremlin server 3.4.0 ?

259 views
Skip to first unread message

Daniel C. Weber

unread,
Feb 5, 2019, 7:08:20 AM2/5/19
to Gremlin-users
I'm sending the query

g.addV(_a).property(_b, _c).property(single, _d, _e).limit(_f)

with bindings "Person", "Age", 29, "Name", "marko", 1 to a Gremlin server 3.4.0 on localhost. The answer is

{
  "@type": "g:List",
  "@value": [
    {
      "@type": "g:Vertex",
      "@value": {
        "id": {
          "@type": "g:Int64",
          "@value": 102
        },
        "label": "Person"
      }
    }
  ]
}

There are no properties included. Also, doing a g.V() will not yield the properties in the json payload.

Connecting to it by Gremlin Console and issuing g.V().properties() shows that the vertex properties do indeed exist.

Everything is fine and works as expected with Gremlin Server 3.3.5.

I use the servers both out-of-the-box. No fancy configs, just extract them from the zip and run them.

Daniel C. Weber

unread,
Feb 5, 2019, 7:14:20 AM2/5/19
to Gremlin-users
Addendum: The "single" cardinality is not significant. g.addV(_a).property(_b, _c).property(_d, _e).limit(_f) doesn't yield any VertexProperties in json either.

Stephen Mallette

unread,
Feb 5, 2019, 7:30:32 AM2/5/19
to gremli...@googlegroups.com
For 3.4.0 we begin to bring all Gremlin Language Variants in line with one another which means that all graph elements (i.e. vertex, edge, vertex property) are returned as references (i.e. without properties). For 3.4.0 we did this only as a configuration change in Gremlin Server via ReferenceElementStrategy which can be removed to regain the old functionality: Please review the upgrade documentation for more information on this important change and others:




--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/2e037916-bf01-4d61-bea8-2091a38da0a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel C. Weber

unread,
Feb 5, 2019, 7:51:11 AM2/5/19
to Gremlin-users
Thanks, it works. Sorry, I missed this in the upgrade notes. Should have read them more carefully.

Now I'm thinking: How can I restore "out-of-the-box" behaviour for the users of my mapper library (ExRam.Gremlinq, you know ;-)).

I liked how the sample app would work just fine on a local gremlin server. Now I would have to instruct on how to reconfigure the server. How would I force the previous behaviour? One possibility is probably to remove the strategy on every traversal, but e.g. CosmosDB would just blow up, it has no notion of strategies (at least not publicly).

Any idea?

Daniel C. Weber

unread,
Feb 5, 2019, 9:32:17 AM2/5/19
to Gremlin-users
Just calling .withoutStrategies(ReferenceElementStrategy) will unfortunately crash on <= 3.3.5. Hopefully none of the established cloud graph databases will adopt this behaviour, because how are we supposed to get a complete vertex structure, properties included, anyway? By querying multiple times?

Stephen Mallette

unread,
Feb 5, 2019, 10:36:30 AM2/5/19
to gremli...@googlegroups.com
>  Just calling .withoutStrategies(ReferenceElementStrategy) will unfortunately crash on <= 3.3.5

yeah, i would expect an error as ReferenceElementStrategy is not a known strategy on 3.3.5 - only introduced on 3.4.0

> Hopefully none of the established cloud graph databases will adopt this behaviour, because how are we supposed to get a complete vertex structure, properties included, anyway? By querying multiple times?

Users shouldn't be returning a full vertex anymore than they should be doing a SELECT * FROM table in SQL. They should be explicit in what properties they want and they should transform their data to more efficient and simple to serialize data structures - at least that is what our best practices advise. 

in a sense all TinkerPop implementations have long had this behavior in that language variants have never supported properties on elements (this is true of python, .NET and js) . The only thing we've done differently now is made that behavior consistent to the JVM by installing ReferenceElementStrategy to force all elements to that form.

i understand that you have a different use case from most users in that you are building a tool that does some object-graph mapping so working with the structural elements of the graph is more of what you need. The closest thing you can get now to retrieving elements without knowing the property keys would be to:

g.V().valueMap().with(WithOptions.tokens)

Though, you might need to use the old style of valueMap(true) to be compatible with CosmosDB and other providers who aren't on 3.4.0 yet.






Daniel C. Weber

unread,
Feb 5, 2019, 1:02:13 PM2/5/19
to Gremlin-users
>>The closest thing you can get now to retrieving elements without knowing the property keys would be to:

>>g.V().valueMap().with(WithOptions.tokens)
>>Though, you might need to use the old style of valueMap(true) to be compatible with CosmosDB and other providers who aren't on 3.4.0 yet.

This will ignore all the meta properties of vertex properties.

I get the rationale behind this decision, but there must be a simple way to opt-out or a clear description on how to work around. The change complicates matters a lot, and I hope you agree that object-graph-mappers are a desirable thing to have if we want graph databases to succeed. Maybe we can discuss this further.

Stephen Mallette

unread,
Feb 5, 2019, 1:42:43 PM2/5/19
to gremli...@googlegroups.com
From a TinkerPop perspective, I think that there is a simple way to opt out at this point and you mentioned it - removing the strategy. If cosmosdb doesn't support that syntax I'm not sure what to do, but I don't think they officially support any specific version of Gremlin with their implementation which makes things rather hard to line up against our versioning scheme.

Daniel C. Weber

unread,
Feb 6, 2019, 12:09:46 PM2/6/19
to Gremlin-users
Alright...well, assume we wanted to force the same structure as before without removing the strategies. The best query I can come up with would be

g.V().as('v').id().as('id').select('v').label().as('label').select('v').local(properties().group().by(label()).as('properties')).select('id', 'label', 'properties')

What do you think? Do you see room for improvement?

Praneeth Dogiparthi

unread,
Feb 6, 2019, 3:48:21 PM2/6/19
to Gremlin-users

g.V().has("users","userid", "u1").outE("following").local(properties().group().by(key()).by(value())).toList();


The above is my query iam getting the empty lists with no properties


output:[{},{},{},{},{},{},{},{},{},{},{},{}]

can you help me plz

Daniel C. Weber

unread,
Feb 6, 2019, 5:23:07 PM2/6/19
to Gremlin-users
Probably because VertexProperties don't have the key set but only the label...try label() instead of key(). Haven't tried it though.

Daniel Kuppitz

unread,
Feb 6, 2019, 6:17:53 PM2/6/19
to gremli...@googlegroups.com
g.V().as('v').id().as('id').select('v').label().as('label').select('v').local(properties().group().by(label()).as('properties')).select('id', 'label', 'properties')

What do you think? Do you see room for improvement?

Would be much easier this way:

g.V().project('id','label','properties').
    by(id).
    by(label).
    by(properties().group().by(label))

However, if you want to materialize everything, you'll probably want to do something more like this:

g.V().project('id','label','properties').
    by(id).
    by(label).
    by(properties().group().
                      by(label).
                      by(group().
                           by(value).
                           by(valueMap())))

Cheers,
Daniel


Daniel C. Weber

unread,
Feb 7, 2019, 2:58:11 AM2/7/19
to Gremlin-users
Thanks, that's indeed much more concise. I found your first solution to be closer to what is output today already, what is the point of your second suggestion? What does the first one miss if the second "materializes everything" ?

Daniel C. Weber

unread,
Feb 7, 2019, 5:57:51 AM2/7/19
to Gremlin-users
Got it, probably meta-properties. I couldn't observe it since I'm using CosmosDB, which includes the meta properties anyway for the .properties step.

Daniel Kuppitz

unread,
Feb 7, 2019, 9:04:19 AM2/7/19
to gremli...@googlegroups.com
The second one doesn't return any elements (vertices, edges, properties), only nested maps with simple keys and values.

Cheers,
Daniel


Reply all
Reply to author
Forward
0 new messages