elasticsearch-dsl-py
elasticsearch-dsl-py copied to clipboard
Store index alias settings under alias name, not index
trafficstars
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'}}}}}
❌ Author of the following commits did not sign a Contributor Agreement: 2aa62cccf7f0950529fdec725d5cd0b7ca992b0e
Please, read and sign the above mentioned agreement if you want to contribute to this project