Update data via "stardog-admin virtual import"

Hi there,

is it possible to use the "virtual import" command in a way that parts of the mapped data is updated instead of simply inserted?

We do have the following scenario:

  • We receive JSON files with a consistent structure on a regular basis
  • The 20 key/value pairs of the JSON are mapped against an according RDF structure
  • 18 out of these 20 key/value JSON pairs are static, the remaining 2 change with every new JSON file we receive.

While no duplicates of the static triplets are created when repeatingly importing, new triplets for the 2 non-static properties are added as "duplicates", i.e.,

A :my_prop 234 .
A :my_prop 567 .

This is of course as intended for an INSERT query which obvioulsy happens behind the scenes; however, is it possible to somehow use an UPDATE query instead (ideally only for these 2 non-static properties)?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.


Sorry for the late response.

The import command doesn't support what you're describing. I'd recommend a solution that uses named graphs. If this use case is one where one import completely replaces another (understanding that much of the two imports is duplicated), you can import into a named graph that contains this import exclusively and clear it before each import. The relevant options are:

        -g <named graph>, --named-graph <named graph>
            Target named graph. If no named graph is specified, the default
            graph will be used. This is the named graph where data will be
            imported into.

            Remove all flag. If this flag is set, all data in destination named
            graph will be removed before the import.

If you need something more precise, where entities that were imported with other predicates need to remain as long as those entities are not reimported with new values for those predicates, you can import into a new, empty, temporary graph each time and then run a couple update queries. Something like these, but test them to make sure they do exactly what you need. In the example, :g1 is the permanent graph and :g2 is the temp.

# Remove statements that the import is going to replace with new values
    GRAPH :g1 {
        ?s ?p ?o1
    GRAPH :g1 {
        ?s ?p ?o1
    GRAPH :g2 {
        ?s ?p ?o2

# Now add the new to the old
ADD :g2 TO :g1

I think most use cases can be solved by retaining a named graph for the old import and importing into a new one, even if the specific queries to do the updates are different.


Or alternatively, since it's just two values, you can extract those two values and make them a part of a SPARQL query where you'd have a lot more control of what exactly gets executed.