当前位置: 动力学知识库 > 问答 > 编程问答 >

rdf - Restrict SPARQL query to a certain kind of Class

问题描述:

I have a SPARQL query to select all resources that has the location "California" within the dbpedia database:

select distinct ?subj where {

?subj dbpprop:location dbpedia:California .

} LIMIT 100

Now my problem is to filter this results, so that I only get ?subj that is a sub-class of a certain Class, e.g. dbpedia:Public_company.

I tried sth. like this:

select distinct ?subj where {

?subj a dbpedia:Public_company .

?subj dbpprop:location dbpedia:California .

} LIMIT 100

but this results in an empty result set.

How can I restrict the ?subj to a be from a certain type of Class?

网友答案:

Your query is the correct way to restrict to instances of a certain class. If you get an empty result set, that simply means that there are no instances found. I briefly looked around in DBPedia and didn't encounter any instances of dbpedia:Public_company. Possibly you have a typo in the class name.

分享给朋友:
您可能感兴趣的文章:
随机阅读: