云搜索请求超过10000 Limi

2024-10-01 05:05:39 发布

您现在位置:Python中文网/ 问答频道 /正文

当我搜索包含超过10000个匹配项的查询时,会出现以下错误:

{u'message': u'Request depth (10100) exceeded, limit=10000', u'__type': u'#SearchException', u'error': {u'rid': u'zpXDxukp4bEFCiGqeQ==', u'message': u'[*Deprecated*: Use the outer message field] Request depth (10100) exceeded, limit=10000'}}

当我搜索范围更窄的关键字和结果更少的查询时,一切正常,不会返回错误。在

我想我得设法限制搜索,但我不知道怎么做。我的搜索功能如下:

^{pr2}$

它的名字是这样的:

results = searcher.execute_query_string(request.GET.get('q', ''))[:100]

如您所见,我试图用startsize属性来限制结果。但我还是得到了错误。在

我一定是误解了如何避免在一个搜索结果中得到超过10000个匹配项。有人能告诉我怎么做吗?在

关于这个主题,我能找到的只有Amazon's Limits,它说你只能请求10000个结果。它没有说明如何限制它。在


Tags: themessageuserequesttype错误errordeprecated
1条回答
网友
1楼 · 发布于 2024-10-01 05:05:39

您正在调用get_all_hits,它将获取查询的所有结果。这就是您的size参数被忽略的原因。在

从文件中:

get_all_hits(query) Get a generator to iterate over all search results

Transparently handles the results paging from Cloudsearch search results so even if you have many thousands of results you can iterate over all results in a reasonably efficient manner.

http://boto.readthedocs.org/en/latest/ref/cloudsearch2.html#boto.cloudsearch2.search.SearchConnection.get_all_hits

您应该调用search,而不是http://boto.readthedocs.org/en/latest/ref/cloudsearch2.html#boto.cloudsearch2.search.SearchConnection.search

相关问题 更多 >