Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug-1942406: Fix search_phase_execution_exception: Result window is too large #6867

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions socorro/external/es/supersearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ def get(self, **kwargs):

# Pagination.
results_to = results_from + results_number
if results_to > 10_000:
# In ES 8+ index.max_result_window defaults to 10,000
# https://www.elastic.co/guide/en/elasticsearch/reference/8.17/index-modules.html
raise BadArgumentError(
"_results_offset",
msg="_results_offset + _results_number cannot be greater than 10,000",
)
search = search[results_from:results_to]

# Create facets.
Expand Down
16 changes: 16 additions & 0 deletions socorro/tests/external/es/test_supersearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,22 @@ def test_get_with_bad_results_number(self, es_helper):
with pytest.raises(BadArgumentError):
api.get(_columns=["date"], _results_number=-1)

def test_get_with_bad_results_offset(self, es_helper):
"""_results_offset + _results_number be <= 10,000"""
crashstorage = self.build_crashstorage()
api = SuperSearchWithFields(crashstorage=crashstorage)

api.get(
_results_offset=10_000 - 50,
_results_number=50,
)

with pytest.raises(BadArgumentError):
api.get(
_results_offset=10_000,
_results_number=50,
)

def test_get_with_enum_operators(self, es_helper):
now = utc_now()
crashstorage = self.build_crashstorage()
Expand Down