mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 22:45:04 +00:00
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() ) {
|
if (hasOnlySuggest() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (scrollContext == null) {
|
|
||||||
long from = from() == -1 ? 0 : from();
|
long from = from() == -1 ? 0 : from();
|
||||||
long size = size() == -1 ? 10 : size();
|
long size = size() == -1 ? 10 : size();
|
||||||
long resultWindow = from + size;
|
long resultWindow = from + size;
|
||||||
int maxResultWindow = indexService.getIndexSettings().getMaxResultWindow();
|
int maxResultWindow = indexService.getIndexSettings().getMaxResultWindow();
|
||||||
|
|
||||||
if (resultWindow > maxResultWindow) {
|
if (resultWindow > maxResultWindow) {
|
||||||
|
if (scrollContext == null) {
|
||||||
throw new QueryPhaseExecutionException(this,
|
throw new QueryPhaseExecutionException(this,
|
||||||
"Result window is too large, from + size must be less than or equal to: [" + maxResultWindow + "] but was ["
|
"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. "
|
+ 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()
|
+ "This limit can be set by changing the [" + IndexSettings.MAX_RESULT_WINDOW_SETTING.getKey()
|
||||||
+ "] index level setting.");
|
+ "] 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) {
|
if (rescore != null) {
|
||||||
int maxWindow = indexService.getIndexSettings().getMaxRescoreWindow();
|
int maxWindow = indexService.getIndexSettings().getMaxRescoreWindow();
|
||||||
|
@ -10,13 +10,22 @@ setup:
|
|||||||
indices.refresh: {}
|
indices.refresh: {}
|
||||||
|
|
||||||
---
|
---
|
||||||
"Request window limits":
|
"Request window limits without scroll":
|
||||||
- do:
|
- 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:
|
search:
|
||||||
index: test_1
|
index: test_1
|
||||||
from: 10000
|
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":
|
"Rescore window limits":
|
||||||
- do:
|
- do:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user