Metadata in Neo4j

82 views
Skip to first unread message

Jaroslav Ramba

unread,
Mar 4, 2015, 7:10:52 AM3/4/15
to ne...@googlegroups.com
Ho,

Let say I have couple nodes and relationships that I want to be hidden. It means when I query something, those will never be in the result. They are not supposed to be part or real data that I have in the database. I know there is no such thing like metadata implemented in Neo4j, but is there any way to avoid it?

This is what I have in mind. I would label those nodes and relationships with something like “_META_DATA”. Then I would receive user’s cypher query - for example:

MATCH (a)-[]-(b)-[]-(c)-[]-(a) RETURN a,b,c

and I would like to add “ignore all nodes and relationships that are labeled with “_META_DATA” so the cypher query would actually ignore those. So I would be looking for something like WHERE every_node and every_relationship NOT labeled “_META_DATA”.

Is there any way to solve this problem?

Mahesh Lal

unread,
Mar 4, 2015, 9:31:25 AM3/4/15
to Neo4j
Assuming that you have the "type" of relationship labelled as "_META_DATA" you could use 
WHERE NOT (a)-[:_META_DATA]-(b)-[:_META_DATA]-(c)-[:_META_DATA]-(a)


-- Thanks and Regards
   Mahesh Lal



--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jaroslav Ramba

unread,
Mar 4, 2015, 3:48:36 PM3/4/15
to ne...@googlegroups.com
The problem is that I do not know the query. All I want is to implement a method, which will accept (as a parameter) any Cypher query and will add clause (such as WHERE NOT) that will execute the same query but will also ignore all nodes and relationships which are labelled as “_META_DATA”. So I would be looking for such filter that will ignore these meta nodes and relationships independently on the rest of the cypher query. Something like WHERE NOT nodes.label=‘_META_DATA’ and relationships.label=‘_META_DATA’. In the example you proposed: MATCH (a)-[]-(b)-[]-(c)-[]-(a) WHERE NOT (a)-[:_META_DATA]-(b)-[:_META_DATA]-(c)-[:_META_DATA]-(a) WHERE clause is dependent on MATCH clause, so to create a general method to add WHERE clause to any cypher query, I would need to parse MATCH pattern first.

Dne středa 4. března 2015 15:31:25 UTC+1 Mahesh Lal napsal(a):

Michael Hunger

unread,
Mar 4, 2015, 9:41:33 PM3/4/15
to ne...@googlegroups.com
MATCH path = (a)-[]-(b)-[]-(c)-[]-(a)
WHERE NONE(n in nodes(path) WHERE n:_META_DATA OR (n)-[:_META_DATA] )
Message has been deleted

Martin Troup

unread,
Mar 8, 2015, 7:46:31 AM3/8/15
to ne...@googlegroups.com

Michael Hunger

unread,
Mar 8, 2015, 7:53:13 AM3/8/15
to ne...@googlegroups.com
I would very probably put a filter in my client processing or write a server extension that takes care of it before returning the data.

Alternatively you can look into a system like structr.org on top of Neo4j  which has schema support and also data level security and handles such things automatically for you.

Also note that your user level cypher queries are super unspecifc cross products across the whole graph and are likely to perform very badly.

Michael


Am 03.03.2015 um 12:01 schrieb Martin Troup <trou...@gmail.com>:

Let say I have couple nodes and relationships that I want to be hidden. It means when I query something, those will never be in the result. They are not supposed to be part or real data that I have in the database. I know there is no such thing as metadata implemented in Neo4j, but is there any way to avoid it? 

This is what I have in mind. I would label those nodes and relationships with something like “_META_DATA”. Then I would receive user’s cypher query - for example:

 MATCH (a)-[]-(b)-[]-(c)-[]-(a) RETURN a,b,c 

and I would like to add “ignore all nodes and relationships that are labeled with “_META_DATA” so the cypher query would actually ignore those. So I would be looking for something like WHERE every_node and every_relationship NOT labeled “_META_DATA”. 

Is there any way to solve this problem? 

Thanks for the reply!

Reply all
Reply to author
Forward
0 new messages