我有一个数据集(通过 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
我想做的事情可能吗?