如何通过 sparql 查询使用自定义顺序获取结果

How to get results using customize order by query with sparql

如果 .nt 数据文件中有一些数据,例如:

<ted> <pre> <a>.
<alice> <pre> <b>.
<ella> <pre> <c>.
<hens> <pre> <d>.
<lee> <ppp> <other>.

我想在自定义中按 <pre> 排序数据。

SPARQL 查询是:

//customize order by
select distinct ?s ?o where {
values (?o ?o_){(<a> 1)(<b> 2)}{?s <pre> ?o}
} order by ?o_` 

结果是

<ted> <pre> <a>
<alice> <pre> <b>

我想获取所有数据,请问是否有其他数据的通配符。

//(<*> 3) is pseudocode
select distinct ?s ?o where {
values (?o ?o_){(<a> 1)(<b> 2)(<*> 3)}{?s <pre> ?o}
} order by ?o_`  

然后就可以得到数据结果了:

<ted> <pre> <a>
<alice> <pre> <b>
<ella> <pre> <c>
<hens> <pre> <d>
<lee> <ppp> <other>

正如@AKSW 评论的那样,解决方案是更改 --

values (?o ?o_){(<a> 1)(<b> 2)(<*> 3)}{?s <pre> ?o}

-- 到 --

values (?o ?o_){(<a> 1)(<b> 2)(UNDEF 3)}