如何在SPARQL查询中过滤简单主题

时间:2018-09-23 10:42:09

标签: sparql geosparql

我想我对SPARQL的基础知识有所了解。有人可以帮忙吗?

我只是通过wnat过滤所有包含RDS数据库的“山”的主题。

Prefix lgdr:<http://linkedgeodata.org/triplify/> Prefix lgdo:<http://linkedgeodata.org/ontology/> 
Select * where { 
?s ?p ?o . 
filter (contains(?s, "Mountain"))
} Limit 1000

查询导致错误:

Virtuoso 22023 Error SL001: The SPARQL 1.1 function CONTAINS() needs a string value as first argument

1 个答案:

答案 0 :(得分:1)

您可以使用以下方法使其“工作”:

Prefix lgdr:<http://linkedgeodata.org/triplify/> Prefix lgdo:<http://linkedgeodata.org/ontology/> 
Select * where { 
?s ?p ?o . 
filter (contains(str(?s), "Mountain"))
} Limit 1000

请注意查询中的其他str

但是,结果是

Virtuoso S1T00 Error SR171: Transaction timed out

我不确定该如何处理。

但原则上是可行的:使用时

Limit 1

你得到

s   p   o
http://linkedgeodata.org/ontology/MountainRescue    http://www.w3.org/1999/02/22-rdf-syntax-ns#type     http://www.w3.org/2002/07/owl#Class
相关问题