【发布时间】:2017-05-30 14:55:07
【问题描述】:
我正在尝试使用 Virtuoso 支持的 bif:contains 关系编写一个 SPARQL 查询来执行轻量级字符串匹配。我想检查标签是否包含单词 A 或 B,所以我使用 union 如下:
SELECT DISTINCT ?s ?o WHERE {
?s <http://www.w3.org/2000/01/rdf-schema#label> ?o .
{?o bif:contains "Ramji"}
union {?o bif:contains "Manjhi"}.
}
但是,这不会编译并引发错误:
Virtuoso 37000 Error SP031: SPARQL compiler: The group does not contain
triple pattern with '$o' object before bif:contains() predicate
SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1 SELECT DISTINCT ?s ?o WHERE {
?s <http://www.w3.org/2000/01/rdf-schema#label> ?o .
{?o bif:contains "Ramji"}
union {?o bif:contains "Manjhi"}.
}
如果只使用union 中的一个子句,则查询有效。请问有什么建议吗?
【问题讨论】: