Search code examples
sparqlxquerymarklogic

How can I distinguish SQL triples from explicit triples?


I am using Template Driven Extraction to generate an SQL view and RDF triples from the same set of documents. The SQL view is used for quick inspection of the raw data, while the triples are used downstream to feed information to a knowledge graph.

I now need to extract the RDF triples into an external file, and I'm struggling with separating out those triples that back the SQL view. The documentation suggests that I should use fixed subjects or predicates in my Sparql query, which is something I can't do because I don't know either of the two beforehand. I tried filtering out the SQL triples in XQuery, but I could not devise a way to detect whether a certain value returned by sem:sparql or a triple returned by cts:triples was one of SQL's or mine.

Any help on how to get a dump of all non-SQL triples out of MarkLogic would be appreciated.

Thanks, Hans


Solution

  • Subjects from SQL views are not real sem:iri's (they are sql:rowID's), so you can use the following to exclude them:

    FILTER( ISIRI(?subject) )
    

    HTH!