Skip to content

Conversation

dima-kov-prepler
Copy link

Requesting index alias settings returns INDEX name, not INDEX ALIAS name, but we still store them under index name.

This causes a problem - it is unsafe to access via[self._name]:

    FancyIndex.init()
  File "/Users/adm/.local/share/virtualenvs/monolith-TtpprQ5c/lib/python3.7/site-packages/elasticsearch_dsl/document.py", line 156, in init
    i.save(using=using)
  File "/Users/adm/.local/share/virtualenvs/monolith-TtpprQ5c/lib/python3.7/site-packages/elasticsearch_dsl/index.py", line 304, in save
    current_settings = self.get_settings(using=using)[self._name]["settings"][
KeyError: 'fancy_index_alias'

Index class:

class FancyIndex(Document):
    class Index:
        name = 'fancy_index_alias'

This PR aims to return the same index settings. but under the alias name.
For example, right now calling self.get_settings() for alias returns:

{'fancy_index': {'settings': {'index': {'routing': {'allocation': {'include': {'_tier_preference': 'data_content'}}}, 'number_of_shards': '1', 'provided_name': 'fancy_index', 'creation_date': '1660750277393', 'number_of_replicas': '1', 'uuid': 'lLCF2d8kQp61zJh3-hrR5g', 'version': {'created': '7100099'}}}}}

while with fix it woud return:

{'fancy_index': {'settings': {'index': {'routing': {'allocation': {'include': {'_tier_preference': 'data_content'}}}, 'number_of_shards': '1', 'provided_name': 'fancy_index', 'creation_date': '1660750277393', 'number_of_replicas': '1', 'uuid': 'lLCF2d8kQp61zJh3-hrR5g', 'version': {'created': '7100099'}}}}, 
'fancy_index_alias': {'settings': {'index': {'routing': {'allocation': {'include': {'_tier_preference': 'data_content'}}}, 'number_of_shards': '1', 'provided_name': 'fancy_index', 'creation_date': '1660750277393', 'number_of_replicas': '1', 'uuid': 'lLCF2d8kQp61zJh3-hrR5g', 'version': {'created': '7100099'}}}}}

@cla-checker-service
Copy link

❌ Author of the following commits did not sign a Contributor Agreement:
2aa62cc

Please, read and sign the above mentioned agreement if you want to contribute to this project

@miguelgrinberg miguelgrinberg added the Category: Bug Something isn't right label Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Category: Bug Something isn't right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants