Search code examples
sparqlmarklogicmarklogic-8named-graphs

Named Graph Support in MarkLogic


I am not understanding how FROM NAMED graph is supported in MarkLogic. I am experimenting with SPARQL queries to find which collection the triples are coming from. The result is really confusing. For example:

select *
FROM <http://x.y.z/c>
FROM NAMED <http://x.y.z/c>
WHERE {
#  GRAPH ?g 
  {?s ?p ?o}
  }

returns a set of triple. However, if I un-comment the line # GRAPH ?g, the following error is returned:

[1.0-ml] XDMP-COLLXCNNOTFOUND: amped-qconsole:qconsole-sparql($query, (), (), (), ()) -- Collection lexicon not enabled

and highlight is on the WHERE { line.

Additionally, the following works and returns a set of triples:

select *
FROM <http://x.y.z/c>
WHERE {
  {?s ?p ?o}
  }

but not this:

select *
FROM NAMED <http://x.y.z/c>
WHERE {
  {?s ?p ?o}
  }

it returns an empty set. Adding the GRAPH ?g line causes the same error as above being returned. I am really confused. Can someone give an explanation of the behavior?


Solution

  • MarkLogic uses collections in its implementation of graphs. There is a note in the GRAPH keyword documentation that mentions the need for the collection lexicon.

    You must enable the collection lexicon when you use a GRAPH construct in a SPARQL query. You can enable the collection lexicon from the database configuration pages or the Admin Interface.

    I'll add that you can also enable the collection lexicon through the Management API.