[英]How to make, in one SPARQL query, three independent queries on three different SPARQL endpoints?
is there a way that I can do three independent queries on on three different SPARQL endpoints, in one SPARQL query? 有没有办法在一个SPARQL查询中对三个不同的SPARQL端点进行三次独立查询? For example, I have three SPARQL endpoints (ie, url1, url2 and url3) and three independent queries I want to make, ie, query1 on url1, query2 on url2 and query3 on url3.
例如,我有三个SPARQL端点(即url1,url2和url3)和我要做的三个独立查询,即url1上的query1,url2上的query2和url3上的query3。 Is it possible that I can conduct the three queries once in one SPARQL query?
我可以在一个SPARQL查询中执行三次查询吗?
I tried the pattern like 我试过这样的模式
SELECT * WHERE {
SERVICE <url1> {query1}
SERVICE <url2> {query2}
SERVICE <url3> {query3}
}
It seems that the query tries to connect results from three queries, because the three queries are independent, the final result is empty. 似乎查询尝试连接三个查询的结果,因为三个查询是独立的,最终结果为空。 If I do three times query one endpoint by one endpoint, each query has returned results.
如果我三次通过一个端点查询一个端点,则每个查询都返回结果。
Thank you very much for your help! 非常感谢您的帮助!
You can use UNION to make 3 separate calls: it is roughly the same as making 3 queries. 您可以使用UNION进行3次单独调用:它与进行3次查询大致相同。
SELECT * WHERE {
{ SERVICE <url1> {query1} }
UNION
{ SERVICE <url2> {query2} }
UNION
{ SERVICE <url3> {query3} }
}
The app may need to know which rows come from which call, so labelling the results can be useful: 应用程序可能需要知道哪些行来自哪个调用,因此标记结果可能很有用:
SELECT * WHERE {
{ SERVICE <url1> { query1 } BIND (<url1> AS ?serviceLabel) }
UNION
{ SERVICE <url2> { query2 } BIND (<url2> AS ?serviceLabel) }
UNION
{ SERVICE <url3> { query3 } BIND (<url2> AS ?serviceLabel) }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.