当使用sem查询三元组时,MarkLogic是否应用推理:sparql针对选定的一组商店?
答案 0 :(得分:4)
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics"
at "/MarkLogic/semantics.xqy";
PREFIX skos: <http://www.w3.org/2004/02/skos/core#Concept/>
sem:sparql("select * { ?c a skos:Concept; rdfs:label ?l }",(),(),
sem:ruleset-store(
("subClassOf.rules", "subPropertyOf.rules"),
sem:store()
)
)
答案 1 :(得分:1)
If you have established some relationships among triples and try to fetch results using a ruleset then it will Marklogic definitely apply reasoning while performing search.
For Example i created the following triple
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX prod: <http://www.example.com/products/>
PREFIX ex: <http://www.example.com/>
INSERT DATA
{
prod:1001 rdf:type ex:Apple;
prod:1002 rdf:type ex:Fruit;
}
Now if you search for all the subjects which are of type apple it will only give you prod:1002
And now establish a relationship among them as
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ex: <http://www.example.com/>
INSERT DATA
{
ex:Apple rdfs:subClassOf ex:Fruit .
}
and set the default ruleset of your database to subClassOf.rules and then run the same query
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ex: <http://www.example.com/>
SELECT ?product
WHERE
{
?product rdf:type ex:Fruit
}
Now it will return you both prod:1001 and prod:1002
also for further details you can visit the marklogic documentation which has a very good description of inferencing. https://developer.marklogic.com/features/semantics/inference-examples