Skip to content

fix: _ensure_index_exists for aliases in OpenSearch#3335

Merged
bogdankostic merged 5 commits into
mainfrom
fix/opensearch/ensure_exists_for_alias
May 20, 2026
Merged

fix: _ensure_index_exists for aliases in OpenSearch#3335
bogdankostic merged 5 commits into
mainfrom
fix/opensearch/ensure_exists_for_alias

Conversation

@tstadel

@tstadel tstadel commented May 20, 2026

Copy link
Copy Markdown
Member

Related Issues

  • fixes _ensure_index_exists for aliases in OpenSearch
Traceback (most recent call last):
  File "/home/haystackd/.local/lib/python3.12/site-packages/haystack/core/pipeline/pipeline.py", line 84, in _run_component
    component_output = instance.run(**inputs_copy)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/haystackd/.local/lib/python3.12/site-packages/haystack_integrations/components/retrievers/opensearch/bm25_retriever.py", line 283, in run
    raise e
  File "/home/haystackd/.local/lib/python3.12/site-packages/haystack_integrations/components/retrievers/opensearch/bm25_retriever.py", line 280, in run
    docs = doc_store._bm25_retrieval(**bm25_args)  # example for BM25Retriever
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/haystackd/.local/lib/python3.12/site-packages/haystack_integrations/document_stores/opensearch/document_store.py", line 1079, in _bm25_retrieval
    self._ensure_initialized()
  File "/home/haystackd/.local/lib/python3.12/site-packages/haystack_integrations/document_stores/opensearch/document_store.py", line 308, in _ensure_initialized
    self._ensure_index_exists()
  File "/home/haystackd/.local/lib/python3.12/site-packages/haystack_integrations/document_stores/opensearch/document_store.py", line 420, in _ensure_index_exists
    properties = mapping[self._index]["mappings"].get("properties", {})
                 ~~~~~~~^^^^^^^^^^^^^
KeyError: 'ALIAS_NAME'

Proposed Changes:

How did you test it?

Notes for the reviewer

Checklist

@tstadel tstadel requested a review from a team as a code owner May 20, 2026 08:30
@tstadel tstadel requested review from sjrl and removed request for a team May 20, 2026 08:30
@github-actions github-actions Bot added integration:opensearch type:documentation Improvements or additions to documentation labels May 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (opensearch)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/opensearch/src/haystack_integrations/document_stores/opensearch
  document_store.py
Project Total  

This report was generated by python-coverage-comment-action

@bogdankostic

Copy link
Copy Markdown
Contributor

The same mapping[self._index] pattern that causes KeyError with aliases still exists in 6 other methods

count_unique_metadata_by_filter at document_store.py:1820
count_unique_metadata_by_filter_async at document_store.py:1863
get_metadata_fields_info at document_store.py:1915
get_metadata_fields_info_async at document_store.py:1948
delete_all_documents (with recreate_index=True) at document_store.py:790-791 (uses index_info[index_name] where index_name = self._index, and indices.get() also keys by the real index name)
delete_all_documents_async (with recreate_index=True) at document_store.py:834-835 (same pattern)

Let's fix those in a separate PR.

@bogdankostic bogdankostic merged commit cdc7455 into main May 20, 2026
12 checks passed
@bogdankostic bogdankostic deleted the fix/opensearch/ensure_exists_for_alias branch May 20, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:opensearch type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants