sparql virtuoso bif:包含在一个联合中

时间:2016-07-06 14:41:01

标签: sparql virtuoso

我正在尝试使用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中的一个子句,则查询有效。有什么建议吗?

2 个答案:

答案 0 :(得分:1)

您的查询在错误的位置拆分。 number.charAt(0)+number.charAt(1) //you are concatenating character at index 0 and index 1 // do this int first = Integer.parseInt(number.substring(0,1)); int second = Integer.parseInt(number.substring(1,2)); if( (first+second)%2 == 1){ // your statement } 的每个部分都必须是完整的模式。查看我的queryresults -

UNION

答案 1 :(得分:0)

只需您可以这样使用:

SELECT DISTINCT ?s ?o WHERE {
?s <http://www.w3.org/2000/01/rdf-schema#label> ?o . 
?o bif:contains "'Ramji' or 'Manjhi'"}