Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-08-2021 08:13 PM
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: 'http://example.com/..'})-[e:hasParameter {parameterValue: "parameter"}]->(m:Literal {value: 'value'})
The resulting RDF, would be:
@prefix n4sch: <neo4j://graph.schema#> .
@prefix n4ind: <neo4j://graph.individuals#> .
<http://example.com/..> n4sch:hasParameter n4ind:3242 .
<<<http://example.com/..> 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:
<<<http://example.com/..> 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" .
Thanks
12-12-2021 05:38 PM
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: 'http://example.com/123', 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 = 'http://example.com/123' return n"}
producing:
@prefix n4sch: <neo4j://graph.schema#> .
@prefix n4ind: <neo4j://graph.individuals#> .
<http://example.com/123> n4sch:parameter "value" .
I don't think a simple statement like this requires RDF_Star. Agree?
Hope this helps.
JB.
12-13-2021 10:15 AM
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:
<<<http://example.com/..> 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.
Philippe
All the sessions of the conference are now available online