Limit batch size when scrolling
Limits the batch size from scrolling using the same setting as interactive search: `index.max_result_window`. Closes #19249
This commit is contained in:
parent
47bd2f9ca5
commit
3ea1360625
|
@ -192,19 +192,23 @@ public class DefaultSearchContext extends SearchContext {
|
|||
if (hasOnlySuggest() ) {
|
||||
return;
|
||||
}
|
||||
if (scrollContext == null) {
|
||||
long from = from() == -1 ? 0 : from();
|
||||
long size = size() == -1 ? 10 : size();
|
||||
long resultWindow = from + size;
|
||||
int maxResultWindow = indexService.getIndexSettings().getMaxResultWindow();
|
||||
long from = from() == -1 ? 0 : from();
|
||||
long size = size() == -1 ? 10 : size();
|
||||
long resultWindow = from + size;
|
||||
int maxResultWindow = indexService.getIndexSettings().getMaxResultWindow();
|
||||
|
||||
if (resultWindow > maxResultWindow) {
|
||||
if (resultWindow > maxResultWindow) {
|
||||
if (scrollContext == null) {
|
||||
throw new QueryPhaseExecutionException(this,
|
||||
"Result window is too large, from + size must be less than or equal to: [" + maxResultWindow + "] but was ["
|
||||
+ resultWindow + "]. See the scroll api for a more efficient way to request large data sets. "
|
||||
+ "This limit can be set by changing the [" + IndexSettings.MAX_RESULT_WINDOW_SETTING.getKey()
|
||||
+ "] index level setting.");
|
||||
}
|
||||
throw new QueryPhaseExecutionException(this,
|
||||
"Batch size is too large, size must be less than or equal to: [" + maxResultWindow + "] but was [" + resultWindow
|
||||
+ "]. Scroll batch sizes cost as much memory as result windows so they are controlled by the ["
|
||||
+ IndexSettings.MAX_RESULT_WINDOW_SETTING.getKey() + "] index level setting.");
|
||||
}
|
||||
if (rescore != null) {
|
||||
int maxWindow = indexService.getIndexSettings().getMaxRescoreWindow();
|
||||
|
|
|
@ -10,13 +10,22 @@ setup:
|
|||
indices.refresh: {}
|
||||
|
||||
---
|
||||
"Request window limits":
|
||||
"Request window limits without scroll":
|
||||
- do:
|
||||
catch: /Result window is too large, from \+ size must be less than or equal to[:] \[10000\] but was \[10010\]/
|
||||
catch: /Result window is too large, from \+ size must be less than or equal to[:] \[10000\] but was \[10010\]\. See the scroll api for a more efficient way to request large data sets\./
|
||||
search:
|
||||
index: test_1
|
||||
from: 10000
|
||||
|
||||
---
|
||||
"Request window limits with scroll":
|
||||
- do:
|
||||
catch: /Batch size is too large, size must be less than or equal to[:] \[10000\] but was \[10010\]\. Scroll batch sizes cost as much memory as result windows so they are controlled by the \[index.max_result_window\] index level setting\./
|
||||
search:
|
||||
index: test_1
|
||||
scroll: 5m
|
||||
from: 10000
|
||||
|
||||
---
|
||||
"Rescore window limits":
|
||||
- do:
|
||||
|
|
Loading…
Reference in New Issue