# Cypher query for retrieving rdf data

**URL:** <https://community.neo4j.com/t/cypher-query-for-retrieving-rdf-data/53456>\
**Category:** Neo4j Graph Platform\
**Created:** [March 16, 2022, 3:34am UTC](https://community.neo4j.com/t/cypher-query-for-retrieving-rdf-data/53456 "2022-03-16T03:34:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shilpaiit](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/shilpaiit/32/21177_2.png) [@shilpaiit](https://community.neo4j.com/u/shilpaiit)\
**Post date:** [March 16, 2022, 3:34am UTC](https://community.neo4j.com/t/cypher-query-for-retrieving-rdf-data/53456/1 "2022-03-16T03:34:48Z")

</div>

Hi

 ![neo4jquery16032022](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/2/0/20444b1f5ac5a5e0c2ed2b1d9ea11c12e6185cbe.jpeg)

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

---

<div class="post-metadata">

**Author:** ![giuseppe\_villan](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/giuseppe_villan/32/11871_2.png) [@giuseppe\_villan](https://community.neo4j.com/u/giuseppe_villan)\
**Post date:** [March 22, 2022, 10:37am UTC](https://community.neo4j.com/t/cypher-query-for-retrieving-rdf-data/53456/2 "2022-03-22T10:37:28Z")

</div>

@shilpaiit

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

```auto
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 :

```auto
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:

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

```

See [Naming rules and recommendations - Cypher Manual](https://neo4j.com/docs/cypher-manual/current/syntax/naming/)

---

<div class="post-metadata">

**Author:** ![shilpaiit](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/shilpaiit/32/21177_2.png) [@shilpaiit](https://community.neo4j.com/u/shilpaiit)\
**Post date:** [March 23, 2022, 2:50am UTC](https://community.neo4j.com/t/cypher-query-for-retrieving-rdf-data/53456/3 "2022-03-23T02:50:58Z")

</div>

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.

 ![neo4jquery230320222](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/7/a/7ad74d3b78ede7fe3bf3f47d9ea22d98c187c0c6.jpeg)

Thanks  
Shilpa

---

<div class="post-metadata">

**Author:** ![shilpaiit](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/shilpaiit/32/21177_2.png) [@shilpaiit](https://community.neo4j.com/u/shilpaiit)\
**Post date:** [March 26, 2022, 8:10am UTC](https://community.neo4j.com/t/cypher-query-for-retrieving-rdf-data/53456/4 "2022-03-26T08:10:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![giuseppe\_villan](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/giuseppe_villan/32/11871_2.png) [@giuseppe\_villan](https://community.neo4j.com/u/giuseppe_villan)\
**Post date:** [April 4, 2022, 9:08am UTC](https://community.neo4j.com/t/cypher-query-for-retrieving-rdf-data/53456/5 "2022-04-04T09:08:27Z")

</div>

@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`:

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

```

or without the space, if your property is `NetworkValueClass`.

Anyway, can you share the result of this query?

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

```
