我正在面对使用SPARQL的奇怪问题。这段代码工作正常上QConsole -XQuery中的SPARQL不返回结果
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy";
declare function local:forex-series (
$from-currency-id as xs:string,
$to-currency-id as xs:string,
$forex-supplier-id as xs:string,
$feed-name-id as xs:string
)
{
let $map := map:map()
let $series-sparql := 'PREFIX series: <http://iddn.icis.com/series/>
PREFIX predicates: <http://iddn.icis.com/predicates/>
PREFIX xmls: <http://www.w3.org/2001/XMLSchema#>
SELECT ?series
WHERE {
?series predicates:to-currency $toCurrencyId ;
predicates:from-currency $fromCurrencyId ;
predicates:forex-provider $forexSupplierId ;
predicates:forex-feed $feedNameId ;
}'
let $_ := map:put($map, "toCurrencyId", sem:iri($to-currency-id))
let $_ := map:put($map, "fromCurrencyId", sem:iri($from-currency-id))
let $_ := map:put($map, "forexSupplierId", sem:iri($forex-supplier-id))
let $_ := map:put($map, "feedNameId", sem:iri($feed-name-id))
return
sem:query-results-serialize(sem:sparql($series-sparql, $map))
};
let $to-currency-id := "http://iddn.icis.com/ref-data/currency/10"
let $from-currency-id := "http://iddn.icis.com/ref-data/currency/18"
let $forex-supplier-id := "http://iddn.icis.com/asset/forex/xe"
let $feed-name-id := "http://iddn.icis.com/asset/forex/current"
return local:forex-series($from-currency-id, $to-currency-id, $forex-supplier-id, $feed-name-id)
但是当加入到XQuery的开发代码并将其部署到模块中它不能正常工作。 sem:sparql在这种情况下不会返回任何内容。
是否有任何设置需要完成?或者我错过了什么?请关注这个问题!
SPARQL查询本身是否返回预期结果? – AKSW
是的,它的确如此。即使从QConsole执行此代码也能正常工作。在部署代码运行时,它只会以意想不到的方式运行。 –
模块是否正在与查询控制台中使用的相同数据库重新运行?您还可以使用带有内存三重存储列表的'$ store'选项来设置查询正在执行的三元组。 – scotthenninger