YUI3 YQL同时使用限制和排序
我有一个 YQL 查询,它组合了一堆 RSS 提要,然后按日期对它们进行排序。它工作得很好,但我希望能够对结果进行分页。
这是我的查询:
select channel.item.title, channel.item.link, channel.item.pubDate, channel.item.description(0) from xml where url in(... urls go here ...) | unique(field='channel.item.link') | sort(field='channel.item.pubDate', descending='true')
问题是 yql 在排序过滤器之前执行 LIMIT 和 OFFSET。因此,如果我有 LIMIT 5,我最终只会得到列表中第一个 RSS feed 的前 5 项……而不是所有组合 feed 的前 5 项。
有没有办法链接查询,以便我可以获得对所有结果进行排序的所有查询,并调用限制我的结果的查询。
感谢您的帮助。
I have a YQL query that combines a bunch of RSS feeds and then sorts them by date. It's working great, but I would like to be able to paginate the results.
Here is my query:
select channel.item.title, channel.item.link, channel.item.pubDate, channel.item.description(0) from xml where url in(... urls go here ...) | unique(field='channel.item.link') | sort(field='channel.item.pubDate', descending='true')
The problem is that yql executes LIMIT and OFFSET before the sort filter. So if I have a LIMIT 5 I end up with only the first 5 items from the first RSS feed in the list ... not the first 5 items of all my combined feeds.
Is there a way to chain queries, so I can get all my query that sorts all the results and the call a query that limits my results.
Thanks for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 truncate(count=5) 获取过滤后的 feed 的前 5 项。
或者具有反向排序的 tail() 方法(上面发布的)也可以工作。
请参阅http://developer.yahoo.com/yql/guide/sorting.html
Use the truncate(count=5) to get the first 5 items of the filtered feed.
Or the tail() method with a reversed sort (posted above) would work as well.
See http://developer.yahoo.com/yql/guide/sorting.html
在另一个方向上使用
tail()
和另外的sort()
怎么样?像这样的事情:
我还没有尝试过这个,我不确定你需要哪种排序顺序,但你肯定可以使用
tail()
。显然没有等效的head()
函数,因此请确保最新的项目是排序后的末尾。欲了解更多信息,请参阅
http://developer.yahoo.com/yql/guide/sorting.html
What about using
tail()
and additionallysort()
in the other direction?Something like this:
I have not tried this and I am not sure which sort order you need but you can for sure use
tail()
. There is no equivalenthead()
function apparently, so make sure the newest items are are the end after your sorting.For further information see
http://developer.yahoo.com/yql/guide/sorting.html