分页 SPARQL 结果 [英] Paginating SPARQL results

查看:77
本文介绍了分页 SPARQL 结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有以下 SPARQL 查询:

Suppose I have the following SPARQL query:

SELECT DISTINCT ?result ?label
WHERE {
  ?result a database:Column .
  ?result rdfs:label ?label .
}
ORDER BY (LCASE(?label))

我可以在查询中添加什么来将结果数量限制为给定的前 10 个?或者最好是第一个 n×10 个结果之后的 10 个结果?我正在尝试实现分页以可视化结果.

What can I add to the query to limit the number of results to the first 10 given? Or preferably, the 10 results after the first n×10 results? I'm trying to implement pagination for visualizing the results.

推荐答案

我正在尝试为一个表实现一个分页系统,该系统将返回的数据可视化.

I'm trying to implement a system of paging for a table that visualizes the returned data.

您想使用限制排序依据偏移.它们在标准中得到了很好的描述:

You want to use limit, order by, and offset. They're described pretty well in the standard:

OFFSET 导致生成的解决方案在指定的时间之后开始解决方案的数量.OFFSET 为零无效.

15.4 OFFSET

OFFSET causes the solutions generated to start after the specified number of solutions. An OFFSET of zero has no effect.

使用 LIMIT 和 OFFSET 选择查询的不同子集除非订单可以通过以下方式预测,否则解决方案将没有用使用 ORDER BY.

Using LIMIT and OFFSET to select different subsets of the query solutions will not be useful unless the order is made predictable by using ORDER BY.

LIMIT 子句设置了解决方案数量的上限回.如果实际解决方案的数量,在应用了 OFFSET 后,大于极限,则至多是极限解数将被退回.

15.5 LIMIT

The LIMIT clause puts an upper bound on the number of solutions returned. If the number of actual solutions, after OFFSET is applied, is greater than the limit, then at most the limit number of solutions will be returned.

在您的情况下,当您每页显示十个结果时,您的查询将显示第四页结果:

In your case, your query would be something like this to show the fourth page of results when you are showing ten results per page:

SELECT DISTINCT ?result ?label
WHERE {
  ?result a database:Column .
  ?result rdfs:label ?label .
}
ORDER BY (LCASE(?label))
LIMIT 10
OFFSET 30

这篇关于分页 SPARQL 结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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