Skip to content

Search: index in small chunks #10914

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

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions readthedocs/projects/tasks/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ def _create_imported_files_and_search_index(
document=PageDocument,
objects=html_files_to_index,
index_name=search_index_name,
# Pages are indexed in small chunks to avoid a
# large payload that will probably timeout ES.
chunk_size=25,
)

# Remove old HTMLFiles from ElasticSearch
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
log = structlog.get_logger(__name__)


def index_objects(document, objects, index_name=None):
def index_objects(document, objects, index_name=None, chunk_size=500):
if not DEDConfig.autosync_enabled():
log.info("Autosync disabled, skipping searh indexing.")
return
Expand All @@ -21,7 +21,7 @@ def index_objects(document, objects, index_name=None):
if index_name:
document._index._name = index_name

document().update(objects)
document().update(objects, chunk_size=chunk_size)

# Restore the old index name.
if index_name:
Expand Down