我正在面對使用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