opensearch-project / opensearch-py

Python Client for OpenSearch
https://opensearch.org/docs/latest/clients/python/
Apache License 2.0
338 stars 170 forks source link

[BUG] Cannot update aliased index through Index.save() #822

Closed tienne-B closed 3 days ago

tienne-B commented 1 week ago

What is the bug?

I am unable to update the mapping of an index which is accessed by opensearch-py through an alias.

The relevant frame from the stack-trace is:

  File "/usr/local/lib/python3.10/site-packages/opensearchpy/helpers/index.py", line 328, in save
    current_settings = self.get_settings(using=using)[self._name]["settings"][
KeyError: 'alias_name'

How can one reproduce the bug?

  1. Create an index and alias pointing to the index
  2. Create a Document (with any field) using the alias's name as the Index.name attribute
  3. Run .get_index().save() on the created Document subclass

What is the expected behavior?

I expect the underlying index to be updated through the alias, as is possible through direct requests.

What is your host/environment?

Using opensearch-py 2.4.2 with CPython 3.10.

Do you have any additional context?

I am willing to create a PR.