Showing results for 
Search instead for 
Did you mean: 

Neo4j literal representation in RDF/RDF* graph

Node Link

I'm currently trying to export a Neo4j graph to RDF, while minimizing the number of triples that is created in the process. One place where I found that the triple could be reduce is in place where we would represent, at least in RDF, a literal. In Neo4j, as far as I know, we can't represent literal since a nodes needs to have key value pairs

For example, if I was to create the following:

CREATE (n:Resource {uri: ''})-[e:hasParameter {parameterValue: "parameter"}]->(m:Literal {value: 'value'})

The resulting RDF, would be:

@prefix n4sch: <neo4j://graph.schema#> .
@prefix n4ind: <neo4j://graph.individuals#> .

<> n4sch:hasParameter n4ind:3242 .

<<<> n4sch:hasParameter n4ind:3242>> n4sch:parameterValue "parameter" .

n4ind:3242 a n4sch:Literal;
  n4sch:value "value" .

Here, we are basically creating a node in place of a literal.

My goal is to have this corresponding RDF notation:

<<<> n4sch:hasParameter "value">> n4sch:parameterValue "parameter" .

Is there a way that I can have this result without exporting the literal node?

n4ind:3242 a n4sch:Literal;
  n4sch:value "value" .



Graph Fellow

Hi @philippe.carrier22 ,
I think it can be a lot simpler than that. If all you want is a resource with a property and a literal value you only need one node and the literal property will be a node property. Here's what I mean:

CREATE (n:Resource {uri: '', parameter: "value"})

then you can serialise this node as rdf using /rdf/<gdb>/cypher as follows:

:post /rdf/neo4j/cypher
{"cypher": "match (n:Resource) where n.uri = '' return n"}


@prefix n4sch: <neo4j://graph.schema#> .
@prefix n4ind: <neo4j://graph.individuals#> .

<> n4sch:parameter "value" .

I don't think a simple statement like this requires RDF_Star. Agree?

Hope this helps.


Hi @jesus.barrasa,
Your solution is indeed simple and would work in the majority of the cases. However in my case, prior to importing data into my graph, I don't have any knowledge of what constitute a parameter. Using this solution would result in a RDF graph without the complete picture of our relation.

Let's look at it contextually:

<<<> n4sch:hasParameter "parameter_name">> n4sch:parameterValue "parameter_value" .

Here, parameter_name can be anything so I need to keep the knowledge of this value being a parameter. This is the reason behind the usage of RDF*. Without it, I would not be able to find the parameters in the resulting RDF graph.

Thinking about it, your solution might work if I was to mapped the resource to the right URI when I import the value inside the graph. But even if it works, right now the ontology that I'm using is following the RDF* solution. So I'm a little bit stuck with what I can do.

Anyway, from what I can understand, I'm assuming that there is presently no solution for what I'm looking, am I right?

Thanks for your help.