使用ES(Elasticsearch)一次进入随机页面 [英] Going to random page at once with ES (Elasticsearch)

查看:128
本文介绍了使用ES(Elasticsearch)一次进入随机页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在界面中,我们具有由Yii1 CGridView小部件显示的行[日志]的列表.DataProvider是ES(ElasticSearch).如果用户只是进入索引页面,则他/她发送请求以按日期和ID降序对前30个结果进行检索[大小= 30,从= 0]

In interface we have list of rows [logs] shown by Yii1 CGridView widget. DataProvider is ES (ElasticSearch). If user just enters index page, he/she sends request to fetch top 30 results [size = 30, from = 0] with descending order by date and id

'sort' => [
    'date' => [
        'order' => 'DESC'
     ],
     'id' => [
        'order' => 'DESC'
     ],
],
'from' => $pageFromPrevious * $this->getSize(),
'size' => $this->getSize()

它正在工作.现在,如果我单击最后一页按钮[CGridView小部件允许/显示该按钮],ES会给我错误

And it's working. Now if I click last page buttom [CGridView widget allows/shows that button], ES gives me error

Result window is too large, from + size must be less than or equal to: [10000] but was [26160]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting

我了解上述错误,并寻找了诸如 search_after scan-scroll 之类的替代方法,但它们似乎不适合我.如果用户单击随机页面,或编辑url [页面编号]或一次转到最后一页?解决此问题的正确方法是什么?有什么建议吗?

I understand the error above, and looked for alternatives like search_after and scan-scroll, but they seem not suitable for me. If a user click random page, or edit url [page number] or go to the last page at once? What are the correct ways to solve this problem. Any advice?

==编辑==附:ES v.6.2

== EDITED == P.S: ES v.6.2

==编辑==

在出现消息"

... from +大小必须小于或等于...

...from + size must be less than or equal to...

"

但是我想找到答案(

我了解上面的错误,并寻找了类似的替代方法search_after和scan-scroll,但它们似乎不适合我

I understand the error above, and looked for alternatives like search_after and scan-scroll, but they seem not suitable for me

)

到"

如何解决问题,当用户选择一次转到最后一页或在第千页的中间

How to solve problem, when user chooses to go to last page at once or at middle of thousandth page

"

Adam T关于"google"的答案似乎是正确的.

And Adam T's answer about "google" seems to be correct.

推荐答案

如果您有足够的内存,一个简单的选择就是将索引设置 index.max_result_window 从10000增加到所需的数字(在这种情况下大约为27000.

If you have sufficient memory, a simple option is to increase the index setting index.max_result_window from 10000 to the number you require (in this case around 27000).

请参见 https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/index-modules.html#dynamic-index-settings

但是,这不会无限扩展-如果将其设置得太大,则会耗尽内存.可能有必要寻找跳到最后一页的替代方法.例如,将示例中的排序顺序更改为"ASC"将有效地为您提供最后一页,而不必先翻阅其他所有页面.

However, this will not scale indefinitely - you'll run out of memory if you set it too big. It might be worth looking at alternatives to jumping to the last page. For example, changing the sort order in your example to 'ASC' would effectively give you the last page without having to page through all the others first.

这篇关于使用ES(Elasticsearch)一次进入随机页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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