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.

Filter node properties to get only Data properties, and not uri or annotations

contzero
Node Link

Hello all,

I am trying to get all data properties associated with a Named Individual and their respective values using "properties(n) " command. But this also display the node's uri and associated annotations.
I would like to only get the data properties, without the uri and annotation properties
Here is the query I am using:

match (n:NamedIndividual)
return properties(n)

The kind of result I get:
{
"Man_Hour": 2,
"label": "M_Assembly_1",
"uri": "http://www.semanticweb.org/xxxx/ontologies/2021/0/MBOM#M_Workstation_Assembly_1"
}
Here for example I would like to only display "Man_Hour": 2
Is there a way to filter the results this way?

Thanks a lot for your help

Mehdi

[EDIT]
I also tried the following:
WITH [0,1,2] as NbKey
UNWIND NbKey as NbreKey
MATCH (n:NamedIndividual)
WHERE keys(n)[NbreKey]<>'uri' and keys(n)[NbreKey]<>'label'
RETURN n.label as Instance, keys(n)[NbreKey] as DataProp,
This query gives me the label of data properties that are not "uri" or "label"
I then tried to display the value of this data property using "n.keys(n)[NbreKey]" but it doesn't seem like Neo4J can process variable dataproperties

1 ACCEPTED SOLUTION

Bennu
Graph Fellow

Hi @contzero ,

This may be a good start for you:

WITH ['uri', 'label'] as bl
MATCH (n:NamedIndividual)
WITH n, [a in keys(n) WHERE not a in bl] as props
UNWIND props as key
return ID(n) as identifier, key, n[key] as val, key + ":" + n[key] as expected

H

View solution in original post

2 REPLIES 2

Bennu
Graph Fellow

Hi @contzero ,

This may be a good start for you:

WITH ['uri', 'label'] as bl
MATCH (n:NamedIndividual)
WITH n, [a in keys(n) WHERE not a in bl] as props
UNWIND props as key
return ID(n) as identifier, key, n[key] as val, key + ":" + n[key] as expected

H

It works perfectly, thanks a lot @agudeloharold13 !