Dbpedia sparql 为我的查询提供了空结果,有什么问题吗?
Dbpedia sparql gives empty result to my query, what is wrong?
我在此 site 中执行 sparql 查询。
它给了我一个空的结果,我的查询有什么问题?
prefix foaf: <http://xmlns.com/foaf/0.1/>
select * where {
?s rdf:type foaf:Person.
} LIMIT 100
这个查询没问题,但是当我添加第二个模式时,我得到的结果是空的。
?s foaf:name 'Abraham_Robinson'.
prefix foaf: <http://xmlns.com/foaf/0.1/>
select * where {
?s rdf:type foaf:Person.
?s foaf:name 'Abraham_Robinson'.
} LIMIT 100
如何更正我的查询以使结果包含此记录:
以下查询应该有效。由于需要刷新与此实例关联的文本索引(当前正在进行中),目前它无法正常工作:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT * where {
?s rdf:type foaf:Person.
?s foaf:name "'Abraham Robinson'".
}
LIMIT 100
请注意 double-quotes 中 single-quotes 中短语的放置方式。
如果文字内容是 language-tagged,就像 DBpedia 中的情况一样,exact-match 查询将采用以下形式(已在@TallTed 的回复中阐明):
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT * where {
?s rdf:type foaf:Person.
?s foaf:name 'Abraham Robinson'@en.
}
LIMIT 100
索引更新完成后,SPARQL Results Page Link 应该会生成一个解决方案。
我想 Kingsley 将其误读为自由文本搜索,而不是简单的字符串比较。
The query Kingsley posted and linked earlier delivers no solution,原因与原始查询失败的原因相同,正如 AKSW 在评论中指出的那样,即 --
foaf:name
值通常不会像原始值那样用下划线替换空格;即,'Abraham_Robinson'
应该是 'Abraham Robinson'
foaf:name
字符串通常带有语言标签,在这种情况下,因此实际上需要 'Abraham Robinson'@en
合并 AKSW 的修复程序 with this line ?s foaf:name 'Abraham Robinson'@en.
, the query works。
综上所述——您可能更喜欢替代查询,无论 foaf:name
值是否被语言标记以及空格是否被下划线替换,该查询都会提供结果。 This one is Virtuoso-specific, and produces results faster 因为 bif:contains
函数使用它的 free-text 索引,将是 --
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
WHERE
{
?s rdf:type foaf:Person ;
foaf:name ?name .
?name bif:contains "'Abraham Robinson'" .
}
LIMIT 100
Generic SPARQL using a REGEX FILTER
works against both Virtuoso and other RDF stores, but produces results more slowly 因为 REGEX
没有利用 free-text 索引,如 --
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
WHERE
{
?s rdf:type foaf:Person ;
foaf:name ?name .
FILTER ( REGEX ( ?name, 'Abraham Robinson' ) ) .
}
LIMIT 100
我在此 site 中执行 sparql 查询。 它给了我一个空的结果,我的查询有什么问题?
prefix foaf: <http://xmlns.com/foaf/0.1/>
select * where {
?s rdf:type foaf:Person.
} LIMIT 100
这个查询没问题,但是当我添加第二个模式时,我得到的结果是空的。
?s foaf:name 'Abraham_Robinson'.
prefix foaf: <http://xmlns.com/foaf/0.1/>
select * where {
?s rdf:type foaf:Person.
?s foaf:name 'Abraham_Robinson'.
} LIMIT 100
如何更正我的查询以使结果包含此记录:
以下查询应该有效。由于需要刷新与此实例关联的文本索引(当前正在进行中),目前它无法正常工作:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT * where {
?s rdf:type foaf:Person.
?s foaf:name "'Abraham Robinson'".
}
LIMIT 100
请注意 double-quotes 中 single-quotes 中短语的放置方式。
如果文字内容是 language-tagged,就像 DBpedia 中的情况一样,exact-match 查询将采用以下形式(已在@TallTed 的回复中阐明):
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT * where {
?s rdf:type foaf:Person.
?s foaf:name 'Abraham Robinson'@en.
}
LIMIT 100
索引更新完成后,SPARQL Results Page Link 应该会生成一个解决方案。
我想 Kingsley 将其误读为自由文本搜索,而不是简单的字符串比较。
The query Kingsley posted and linked earlier delivers no solution,原因与原始查询失败的原因相同,正如 AKSW 在评论中指出的那样,即 --
foaf:name
值通常不会像原始值那样用下划线替换空格;即,'Abraham_Robinson'
应该是'Abraham Robinson'
foaf:name
字符串通常带有语言标签,在这种情况下,因此实际上需要'Abraham Robinson'@en
合并 AKSW 的修复程序 with this line ?s foaf:name 'Abraham Robinson'@en.
, the query works。
综上所述——您可能更喜欢替代查询,无论 foaf:name
值是否被语言标记以及空格是否被下划线替换,该查询都会提供结果。 This one is Virtuoso-specific, and produces results faster 因为 bif:contains
函数使用它的 free-text 索引,将是 --
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
WHERE
{
?s rdf:type foaf:Person ;
foaf:name ?name .
?name bif:contains "'Abraham Robinson'" .
}
LIMIT 100
Generic SPARQL using a REGEX FILTER
works against both Virtuoso and other RDF stores, but produces results more slowly 因为 REGEX
没有利用 free-text 索引,如 --
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT *
WHERE
{
?s rdf:type foaf:Person ;
foaf:name ?name .
FILTER ( REGEX ( ?name, 'Abraham Robinson' ) ) .
}
LIMIT 100