次の SPARQL クエリを実行できるデータセット (D2RQ 経由で公開) を取得しました。
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" -
ここまでは順調です...今度は、Liverpool に言及している行を返したいと思います。
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
ましたが、役に立ちませんでした。
私がやろうとしていることは可能ですか?