我的三重存储(GraphDB)中有超过2000个资源,我想根据它们的IRI按升序排序,而IRI看起来像:
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#3
...
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2345
在我的图中,所有上述IRI通过“DE6:complex_Data_Type_has_Member”连接到一个资源。为了获得所有上述IRI,我执行以下操作:
PREFIX DE6: <http://DE6/DINEN61360#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?IRIs_to_Sort WHERE{
?Array a DE6:Data_Element;
DE6:complex_Data_Type_has_Member ?IRIs_to_Sort .
} ORDER BY ?IRIs_to_Sort
如果我只使用“ORDER BY?IRIs_to_Sort”解决方案序列修饰符,那么如https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#modOrderBy所示
然后我得到以下结果(只显示前十个结果):
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#10
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#100
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1000
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1001
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1002
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1003
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1004
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1005
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1006
...
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1999
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#20
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#200
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2000
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2001
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2002
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2003
...
相反,我希望有类似的东西:
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#3
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#4
...
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2099
我在这里错过了什么?
IRI被视为ORDER BY
的词汇值,这意味着您的片段ID中的数字被视为文本,并且它们不会被单独考虑。
我认为一个完整的ORDER BY
会对你有用,无论你的结果集是否包含一个或多个每个都有一个或多个frag-ID的IRI,但只有当所有的frag-ID都是数字时,才会 -
ORDER BY ( xsd:string ( STRBEFORE ( STR ( ?IRIs_to_Sort ), "#" ) ) )
( xsd:long ( STRAFTER ( STR ( ?IRIs_to_Sort ), "#" ) ) )
如果您的frag-ID是数字和字母数字的混合,事情会变得更加复杂。