cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Cypher query for retrieving rdf data

Hi

Attached is the node in my graph database. I am trying run a cypher query to retrieve the node.
My queries were

  1. match (a) where a.id=203
    return a
    Result :no records were retrieved

  2. match (a) where a.rdf-schemaCreationSource='SURVEY'
    return a
    Result : Variable schemaCreationSource not defined (line 1, column 23 (offset: 22))"match (a) where a.rdf-schemaCreationSource='SURVEY'"**

Please let me know the correct syntax.

Thanks
Shilpa

4 REPLIES 4

@shilpaiit

To retrieve a node via the internal id, that is the property with key <id>,
you should execute this:

match (a) where id(a) =203
return a

Just for clarity, you could create a node with an id property, in that case you would have to match (a) where a.id = 203 return a, but still that would be a different property than the id created internally by Neo4j.

In the second case, the property rdf-schemaCreationSource has a character -,
therefore you have to escape it, using the backtick :

match (a) where a.`rdf-schemaCreationSource`='SURVEY'
return a

Anyway, I notice that the property value has square brackets,
so maybe the query should be:

match (a) where a.`rdf-schemaCreationSource`='[SURVEY]'
return a

See Naming rules and recommendations - Neo4j Cypher Manual

Further to the above query. Below images shows the node labels in my database and the cypher query .
The result retrieved a null value.
Please le me know the correct query to retrieve data in the Resource node.

Thanks
Shilpa

Hi

I made some progress. Now
CALL n10s.inference.nodesLabelled('Resource')
yield node
return node.ContactPerson as Owner,node.Representation as Geometry,node.InteriorDiameter as Diameter, node.Material as Material
Is working as expected.
But I cannot retrieve individual nodes using match and return clauses. To be more specific.
Match (a:Resource)
Return a. InternalDiameter works well.
Match (a:Resource {NetworkValue Class:"XYX"})
Return a doesn't work. It says no records.
How to retrieve individual node based on a condition?

@shilpaiit

Hi, the syntax seems correct, that is (match :Node keyProperty:"valueProperty"),
but maybe after pasting the query here, it is been formatted badly,
Match (a:Resource {NetworkValue Class:"XYX"}) ,
with a whitespace between NetworkValue and Class throws a syntax exception.

You should write in this way if your property is NetworkValue Class:

 Match (a:Resource {`NetworkValue Class`:"XYX"})

or without the space, if your property is NetworkValueClass.

Anyway, can you share the result of this query?

MATCH (n:Resource)
WITH DISTINCT KEYS(n) AS keys
UNWIND keys AS key
RETURN DISTINCT COLLECT(DISTINCT key)