如何增加 freebase API 结果限制
我在 freebase 的文档中找不到任何相关内容,但他们似乎将结果数量限制为 100 个。例如:
[{
"type":"/base/popstra/celebrity",
"name":null
}]
仅返回 100 个结果,而
[{
"type":"/base/popstra/celebrity",
return:"count"
}]
说有 6244 个结果。有谁知道如何获得其余的吗?我知道我可以通过一些参数(例如国家/地区)限制查询,然后汇总结果,但我更喜欢不那么老套的东西。
I can't find anything in freebase's docs about it but it seems they limit the number of results to 100. For example:
[{
"type":"/base/popstra/celebrity",
"name":null
}]
Returns only 100 results whereas
[{
"type":"/base/popstra/celebrity",
return:"count"
}]
Says there are 6244 results. Does anyone know how to get the rest of them? I know I can limit the queries by some parameter like country and then aggregate the results but I'd prefer something less hacky.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
limit
属性来请求更多结果。但是,获取大量数字可能会导致查询超时。更可靠的方法是使用
cursor
属性。传入cursor
值为true
。您将获得一批结果,但您还将在响应中获得cursor
的新值。重复您的查询,但替换为新的光标
值以获取下一批结果。通过这种方式,您甚至可以获取非常大的数据集。更多信息:http://www.freebase.com/docs/mql/ch04。 html#envelopeparameters
You can use the
limit
property to request more results. However, fetching large numbers can give you a query timeout.A more reliable way is to use the
cursor
property. Pass in acursor
value oftrue
. You'll get a batch of results, but you'll also get a new value forcursor
in the response. Repeat your query, but substitute in the newcursor
value to get the next batch of results. In this way you can fetch even a very large set of data.More info: http://www.freebase.com/docs/mql/ch04.html#envelopeparameters
一位同事帮我解决了这个问题。我认为我应该使用
limit
参数,但我没有把它放在正确的位置。其操作方法如下:A coworker helped me figure this one out. I thought I should use the
limit
parameter but I didn't put it in the right place. Here's how it's done: