如何按BlankNode ID进行过滤 [英] How to filter by 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:
-
FILTER REGEX(str(?value), "#bnode-id")
-
FILTER (?value), "#bnode-id")
FILTER REGEX(str(?value), "#bnode-id")
FILTER (?value), "#bnode-id")
但没有一个成功.
- 您如何根据bnode ID进行过滤?
- 是否可以 STR(bnode)?
推荐答案
- 您如何根据bnode的
id标签进行过滤?
- How would you filter based on a bnode
idlabel?
请参见 空白节点标签信息.简而言之,不能依赖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)
}
- 有可能
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屋!