Search code examples
sparqlmarklogic

MarkLogic: Constrain SPARQL query scope by triple-range-query constraint


I would like to evaluate a SPARQL query against a limited document scope, which is based on a triple range query. Only embedded triples contained by documents which match a specific triple pattern should be part of the SPARQL evaluation scope. I'm using the Java SDK (via marklogic-rdf4j) to evaluate the SPARQL query. We're only using embedded/unmanaged triples.

I'm aware of the possibility to attach a structured query definition to a SPARQL query (by calling MarkLogicQuery::setConstrainingQueryDefinition), but the structured query syntax does not support triple-range-query constraints.

Is there any way to apply one or more triple-range-query constraints in a structured query definition? Or are there better alternatives?


Solution

  • Support for triple-range-query in structured queries has been requested before. I added your case to the ticket.

    In the mean time you might get away with using a custom constraint. Me and a colleague put this together:

    https://github.com/patrickmcelwee/triple-range-constraint/blob/master/triple-range-constraint.xqy

    HTH!