querying a DB for an unknown element with a given uuid

14 views
Skip to first unread message

Paolo Di Pietro

unread,
Jun 25, 2017, 1:20:24 PM6/25/17
to Neo4j
Hi all, Lot of years ago, I discussed with some neo4j engineers about the ability to query an unknown object given it's uuid.

At that time, the answer was that there was no general db index in neo4j.

Now, I have the same problem to solve:

each node I create has an unique id (uuid in the form <nx:u-<uuid>-?v=n> where ns is the namespace, uuid is a unique uuid and v=n is the version number of the element.

I'd like to have the ability to run the following cypher query:

match (n) where n:about = 'ki:u-SSD-v5.0?v=2' return n;

which actually return nothing.

The following query 

match (n:'mm:ontology') where n:about = 'ki:u-SSD-v5.0?v=2' return n;

returns what I need, despite the fact that at query time I don't know the element type.

Can anyone help on this?

Paolo

Clark Richey

unread,
Jun 25, 2017, 2:16:02 PM6/25/17
to ne...@googlegroups.com
Your syntax is incorrect. Properties are accessed via . Notation not :  http://neo4j.com/docs/cypher-refcard/current/

Anyways....you can match on an indexed
Property of an unknown type but it won't perform well at scale as the db has to do a node scan of all nodes. This is because indexes are tied to a node label. A better practice would be to include the node label in the identifier so that you can parse it out and correctly determine the node type. Then the query will be fast. 

Sent from my iPhone
--
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.

Paolo Di Pietro

unread,
Jun 28, 2017, 8:51:05 AM6/28/17
to Neo4j
well, the error was a typo.

I solved the problem by adding a second label (node) to every node in the model, andcreating a constraint on the uuid element/attribute.

Performance have to beisured, but seems not being a problem

Paolo
Reply all
Reply to author
Forward
0 new messages