我对rdf sparql没有多少经验,只是偶尔我会做一些非常简单的事情。以下是我的数据的两个样本:
select * from allSchema.SomeTable where schemaName in ('schema1','schema2')
@prefix ew: <http://ew.com/content/> .
@prefix sesame: <http://www.openrdf.org/schema/sesame#> .
ew:50467332 ew:name "He resigns, citing PTSD"^^xsd:token ;
ew:section "health"^^xsd:token ;
dc:isPartOf <http://ew.go.com/Health> ;
dc:created "2018-01-08T13:54:14.340-08:00"^^xsd:dateTime ;
dc:date "2018-01-08T18:23:47.000-05:00"^^xsd:dateTime ;
dc:identifier "50467332"^^xsd:int ;
dc:modified "2018-01-08T15:24:01.547-08:00"^^xsd:dateTime .
我有rdf三元组,其中ew:section可以有很多变化,但我只想找到这两个变体,即:
@prefix ew: <http://ew.com/content/> .
@prefix sesame: <http://www.openrdf.org/schema/sesame#> .
ew:50477535 ew:name "Having a Baby in Your 40s"^^xsd:token ;
ew:section "agm"^^xsd:token ;
dc:isPartOf <http://ew.go.com/agm/Wellness> ;
dc:created "2018-01-09T08:32:57.047-08:00"^^xsd:dateTime ;
dc:date "2016-08-18T09:52:00.000-04:00"^^xsd:dateTime ;
dc:identifier "50477535"^^xsd:int ;
dc:modified "2018-01-09T08:32:57.047-08:00"^^xsd:dateTime .
我正在测试的查询现在将它们都放在OPTIONAL块中,但我得到的结果是各种“部分”的混合,以及我感兴趣的那些。我怎么才能找到那2节?我知道我收到了不需要的数据,因为我的部分是“可选的”,但我不确定如何使它们同样“重要”。我现在正试图使用UNION,但没有积极的结果。很感谢你的时间。这是我的疑问:
ew:section "health"^^xsd:token ;
and
ew:section "agm"^^xsd:token ;
答案 0 :(得分:0)
最适合我的是使用'OR',如下所示:
?match ew:section "health OR http\\\\:\\\\/\\\\/purl.org\\\\/dc\\\\/terms\\\\/isPartOf:http\\\\:\\\\/\\\\/ew.go.com\\\\/agm\\\\/Wellness"^^xsd:token;