如何按BlankNode ID进行过滤 [英] How to filter by BlankNode id

查看:110
本文介绍了如何按BlankNode ID进行过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 GraphDB 上的SPARQL游乐场中运行此查询.

I'm trying to run this query in the SPARQL playground on GraphDB.

select * where { 
    ?s content:value ?value .
    FILTER REGEX(str(?value), "_:x1697BD364N0abcdd866d54")
} 

?value是BNodes

我正在尝试过滤BNode ID为以下所有值: _:x1697BD364N0abcdd866d54

I'm trying to filter all values where the BNode ID is: _:x1697BD364N0abcdd866d54

我尝试了几种不同的方式来过滤ID:

I've tried a few different ways to filter by the ID:

  1. FILTER REGEX(str(?value), "#bnode-id")
  2. FILTER (?value), "#bnode-id")
  1. FILTER REGEX(str(?value), "#bnode-id")
  2. FILTER (?value), "#bnode-id")

但没有一个成功.

  1. 您如何根据bnode ID进行过滤?
  2. 是否可以 STR(bnode)?

推荐答案

  1. 您如何根据bnode的 id 标签进行过滤?
  1. How would you filter based on a bnode id label?

请参见 标签信息.简而言之,不能依赖SPARQL查询中的空白节点标签:

See the blank-nodes tag info. In short, one can't rely on blank node labels in SPARQL queries:

结果集中的标签_:a与具有相同标签的数据图中的空白节点之间不必存在任何关系.

There need not be any relation between a label _:a in the result set and a blank node in the data graph with the same label.

应用程序编写者不应期望查询中的空白节点标签引用数据中的特定空白节点.

An application writer should not expect blank node labels in a query to refer to a particular blank node in the data.

如果很难通过SPARQL中的空白节点的属性等来区分空白节点,则可以使用GraphDB的内部资源标识符.

If it is hard to distinguish blank nodes by their properties etc. in SPARQL, one can use GraphDB's internal resource identifiers.

PREFIX ent: <http://www.ontotext.com/owlim/entity#>
SELECT * {
    ?s content:value ?value .
    ?s ent:id ?id .
    FILTER (?id = 424242)
}

PREFIX ent: <http://www.ontotext.com/owlim/entity#>
SELECT * {
    ?s content:value ?value 
    BIND (ent:id(?s) AS ?id)
    FILTER (?id = 424242)
}


  1. 有可能STR(bnode)吗?

不.来自 17.4.2.5 str :

simple literal  STR (literal ltrl)
simple literal  STR (IRI rsrc)

返回ltrl的词法形式(文字);返回rsrc(一个IRI)的代码点表示形式.

Returns the lexical form of ltrl (a literal); returns the codepoint representation of rsrc (an IRI).

这篇关于如何按BlankNode ID进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆