sparqlmarklogicinferenceinference-engine

Undefined function sem:sparql-update() while trying to run inference example


I am trying to run the following inference example on ML 8.0 and it is complaining

"[1.0-ml] XDMP-UNDFUN: (err:XPST0017) Undefined function sem:sparql-update()"

Can anyone give an idea why this problem would come up?

http://docs.marklogic.com/guide/semantics/inferencing?print=yes

import module namespace sem = "http://marklogic.com/semantics" 
  at "/MarkLogic/semantics.xqy";
let $sup :=
'
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

INSERT DATA
{ <someMedicalCondition> rdf:type <osteoarthritis> .
  <osteoarthritis> rdfs:subClassOf <bonedisease> . }'
return sem:sparql-update($sup)
; (: transaction separator :)

let $sq := 
'PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX d: <http://diagnoses#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?diagnosis
WHERE { ?diagnosis rdf:type <bonedisease>. } '

let $rs := sem:ruleset-store("rdfs.rules", sem:store())  
(: rdfs:rules is a predefined rule set in <MarkLogic-install-dir>/Config :)
return sem:sparql($sq, (), (), $rs)  
(: the rules specify that query for <bonedisease> will return the subclass <osteoarthritis> :)

Solution

  • The sem:sparql-update() function has been available since 8.0-1. I just did a clean install of MarkLogic 8.0-2 and ran the code you have above and it worked fine. That makes me wonder whether there was a problem with the install. Perhaps you upgraded from an early access release to 8.0-2? (Upgrades from early access releases are not supported, and sometimes weird things happen.)

    Regardless, if you have meaningful data in your database, I would export it and do a clean install (uninstall; remove the data directory), then re-import your data. MLCP can help you with this.

    As long as you're doing these steps, you might as well step up to the current release, 8.0-3.

    Side note: some of the semantics functions are implemented in XQuery as libraries; some are built-in functions implemented in C++. That's likely why you didn't see sparql-update() in the semantics.xqy library.