我有一个数据集(通过D2RQ公开),我可以从中运行以下SPARQL查询
SELECT ?index ?freetext ?label WHERE
{
?s a prov:Agent ;
skos:notation ?index.
?s skos:description ?freetext .
OPTIONAL { ?s skos:prefLabel ?label }
}
并得到一个明智的结果:
index freetext label
--------------------------
1 "Some text containing Manchester" "Lancashire"
2 "Some text containing Liverpool" -
3 "Some text containing Manchester and Liverpool" "The North"
4 "Some text containing London" -
到目前为止这么好......现在,我想回到提到利物浦的行:
SELECT ?index ?freetext ?label WHERE
{
?s a prov:Agent ;
skos:notation ?index.
?s skos:description ?freetext .
OPTIONAL { ?s skos:prefLabel ?label }
FILTER (regex(str(?freetext), "Liverpool", "i"))
}
我要返回
index freetext label
--------------------------
2 "Some text containing Liverpool" -
3 "Some text containing Manchester and Liverpool" "The North"
但这会再次返回所有4行 - 即过滤无效。我已经尝试了FILTER EXISTS
,FILTER NOT EXISTS
,MINUS
,subquerying等我能想到的所有组合,但无济于事。
我尝试做的是什么?