curator.actions.IndexSettings missing in Curator python lib?

I'm trying to use the IndexSettings action class in the curator python library:

ilo = curator.IndexList(es)
e= curator.actions.IndexSettings(ilo.all_indices, index_settings={"number_of_replicas": 1})

And I have this result:

AttributeError: module 'curator.validators.actions' has no attribute 'IndexSettings'

What am I doing wrong? I checked in the module source, and the class IndexSettings is here.

Thanks in advance!

First off, The IndexSettings object expects an IndexList object, but you are passing ilo.all_indices, which is not an IndexList object but a regular list. The proper way to use an IndexList object is to use the filter methods, and pass the whole object. If you apply no filter methods, all indices is implicit.

Second, I sincerely apologize for the way that the documentation makes it appear as though you need to call curator.actions.IndexSettings. Because of the way it's lumped into __init__.py, it must be referenced by curator.IndexSettings, otherwise you'll get an exception:

AttributeError: 'module' object has no attribute 'IndexSettings'

Using the full path was the only way I could make it print out properly using Sphinx documentation. The plus side, though, is that you can reference pretty much all of the classes and functions directly this way: curator.CLASS or curator.FUNCTION.

Third, you're missing the 'index' root key for your index_settings. It must be {'index':{'number_of_replicas':1}}

After a few edits, this should work for you:

import elasticsearch
import curator
client = elasticsearch.Elasticsearch()
# This step is to add an index, as this is a test install with nothing else...
curator.CreateIndex(client, extra_settings={'settings':{'index.number_of_replicas':0}}, name='my_index').do_action()
ilo = curator.IndexList(client)
e = curator.IndexSettings(ilo, index_settings={"index":{"number_of_replicas": 1}})
e.do_action()

I tested this on a clean, single-node instance of Elasticsearch. The cluster health was "green" when I added the index, because I set it to have 0 replicas. It was "yellow" after running the IndexSettings action because the number_of_replicas was set to 1, but there's only 1 node, so the replica can't be created.

1 Like

Yeah! It works!!

Thank you so much Aaron! :+1:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.