用 yql 获取随机行?

发布于 2024-11-19 03:23:41 字数 288 浏览 6 评论 0原文

我想使用 javascript 从 flickr 中使用 yql 获取数据, 例如

select id from flickr.photos.search(10) where text = 'music' and license=4

,但是,我想获取 10 个随机行,而不是最新的,因为最新的往往是来自同一个人的 10 张照片。

yql 本身有可能(我怀疑不可能), 或任何可以带来相同效果的解决方法? (它不必是完全随机的,我主要想避免的是从同一张海报中获取 10 张照片)

I want to use javascript to fetch data with yql from flickr,
e.g.

select id from flickr.photos.search(10) where text = 'music' and license=4

however, I would like to fetch 10 random rows, rather then the latest, since the latest tend to be 10 photos all from the same person.

ist that possible in yql itself (I suspect not),
or any workarounds that could bring the same effect?
(it does not have to be complete random, the main thing I want to avoid is to get 10 photos from the same poster)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绳情 2024-11-26 03:23:41

要仅获取唯一所有者的结果,您可以使用unique()函数(文档)。

我的建议是查询更大的结果集(更有可能有 10 个不同的人),然后调用 unique() ,然后调用 truncate() 将结果限制为 10 个,如下。

select id from flickr.photos.search(100) where text = 'music' and 
license=4 | unique(field="owner") | truncate(count=10)

To get only results from unique owners, you can use the unique() function (docs).

My suggestion would be to query for a larger result set (more likely to have 10 unique people) then call unique() followed by truncate() to limit to 10 results, as below.

select id from flickr.photos.search(100) where text = 'music' and 
license=4 | unique(field="owner") | truncate(count=10)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文