neo4jrdfrdflib

How to add a list as an attribute value when using Neo4j's rdflib parser


Suppose I have an RDF .ttl file that includes:

<https://example/Product_1> <http://www.w3.org/ns/dcat#keyword> "health".
<https://example/Product_1> <http://www.w3.org/ns/dcat#keyword> "fitness".
<https://example/Product_1> <http://www.w3.org/ns/dcat#keyword> "sports".

I have noticed that if I use rdflib to import this data to Neo4j, using the code described here, things work but only one of the values for the keyword is being imported for my product. Which makes sense because for the "key" keyword we can only have one value. So is there a way that I can make parser parse my .ttl file such that it creates something like:

(n:Product {Keyword:["sports","fitness", "health"]})


Solution

  • Specify the Neo4jStoreConfig option handle_multival_strategy=HANDLE_MULTIVAL_STRATEGY.ARRAY to store a list of keyword values instead of just a single value.

    See this test file for some examples of code that does that.