Hide/Exclude Certain Properties

196 views
Skip to first unread message

S. Aden

unread,
Nov 8, 2019, 11:54:43 AM11/8/19
to Gremlin-users
Hi Folls,

My vertices contains metadata properties that I need to hide from query results. What's the best way to do this?

I am aware providers can hide metadata using Graph.Hidden and was wondering if there is something similar that allows users to hide properties too?

Stephen Mallette

unread,
Nov 11, 2019, 6:41:25 AM11/11/19
to gremli...@googlegroups.com
When you say "metadata properties", do you just mean vertex properties that you've defined as meta data yourself? You're not referring to meta-properties, right?


--
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/c9a4ed38-b842-4591-8a9c-9ca07946e9ff%40googlegroups.com.

Josh Perryman

unread,
Nov 11, 2019, 8:52:09 AM11/11/19
to Gremlin-users
If your entities have data and metadata, then I can think of a few ways to restrict access to the metadata, namely: 

1. Explicitly list property keys in queries so that metadata isn't returned. This is managing access in your application code with the values(), valueMap() and elementMap() steps, like this:

g.V().has('my_label','my_key','value').values('my_key','my_other_key').next()

This is usually the easiest approach and is a best practice, akin to using SELECT id, name FROM table; instead of SELECT * FROM table;.

2. Add another vertex label just for storing metadata.  This means having to traverse an edge to set / get metadata, which adds complexity to the design and application logic. But if the metadata is rarely accessed, then it can be a fairly simple way of hiding the properties. 

Note that this backs into a "layered" design to the graph with some of the elements being in the primary application layer, and others being in the metadata layer.  If partitioning the graph like this one should also partition the application code similarly. 

3. Use meta-properties to control visibility of properties.  There's a certain elegance to this approach, but there's a few of caveats. 

First, not all graph databases support meta-properties. Second, they often don't perform well in high I/O situations (e.g. data ingest). Third, they may not be honored by the indexing engine.  

But on the positive side, they can be combined with a SubgraphStrategy (if supported by the implementation) to simplify the application logic. See the Gremlin's Time Machine blog post for more details. 

Have fun!

-Josh

S Aden

unread,
Dec 27, 2019, 7:47:16 PM12/27/19
to Gremlin-users
I mean vertex properties that I defined as meta data property myself. As an example, I would like to associate an organization metadata property to every vertex which I would like to hide from query results returned to the client. Ideally I would like to leverage something like subgraph strategy to do this.

S Aden

unread,
Dec 27, 2019, 8:07:01 PM12/27/19
to Gremlin-users
Thanks for the reply. The first and second suggestion requires the user to have knowledge of the data model which doesn’t work for my use-case. The third solution is what I was hoping to implement. Ideally database support shouldn’t be necessary if I could define a “PropertExclusionStragey” for my graph in conjunction with other strategy. Does that make sense?
Reply all
Reply to author
Forward
0 new messages