Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alias action that deletes an index #20064

Closed
nik9000 opened this issue Aug 18, 2016 · 4 comments
Closed

Add alias action that deletes an index #20064

nik9000 opened this issue Aug 18, 2016 · 4 comments
Assignees
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates >enhancement v5.0.0-beta1

Comments

@nik9000
Copy link
Member

nik9000 commented Aug 18, 2016

If we add an alias action that deletes an index then we can swap an existing index with an alias in one request which applies the cluster state change atomically. This is quite useful because while the best practice is to address Elasticsearch indexes through aliases not everyone does that all the time. This will give folks who aren't using an alias an easy way to do it. Something like:

curl -XPOST 'http://localhost:9200/_aliases?pretty' -d '{
    "actions" : [
        { "delete_index" : { "index" : "important_stuff" } },
        { "add" : { "index" : "important_stuff_1471541773", "alias" : "important_stuff" } }
    ]
}'

It is super nice to do this in one action because:

  1. The cluster state update is atomic so if there is any failure adding the alias then the index isn't deleted.
  2. There is no time where a search for the index name comes back with no results. There would be, unfortunately, some time where the results can be a bit confused because index names aren't resolved to a permanent ID on the coordinating node. A procedure like this will minimize that time though.
@nik9000
Copy link
Member Author

nik9000 commented Aug 18, 2016

@clintongormley, we discussed this earlier today. It is an important precondition to doing #20024 and good even if we decide not to do #20024.

@clintongormley
Copy link

Great Nik. The only thing is that I'd change delete-index to delete_index to be consistent with other parameters.

@nik9000
Copy link
Member Author

nik9000 commented Aug 19, 2016

Yeah, I'll do that. I noticed yesterday that this is one place where we
still support camelCase in and funny-dash-case and our normal snake_case.
Shall I drop support for the other two while I'm there? Camel case is
officially deprecated so that seems safe.

On Aug 19, 2016 7:33 AM, "Clinton Gormley" notifications@github.com wrote:

Great Nik. The only thing is that I'd change delete-index to delete_index
to be consistent with other parameters.


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#20064 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AANLojqzvG1VqzIEnXCY6tBFY-b6or5Rks5qhZSCgaJpZM4JnvD3
.

@clintongormley
Copy link

Shall I drop support for the other two while I'm there?

+1

nik9000 added a commit to nik9000/elasticsearch that referenced this issue Aug 30, 2016
While removing an index isn't actually an alias action, if we add
an alias action that deletes an index then we can delete and index
and add an alias with the same name as the index atomically, in
the same cluster state update.

Closes elastic#20064
@clintongormley clintongormley added :Data Management/Indices APIs APIs to create and manage indices and templates and removed :Aliases labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates >enhancement v5.0.0-beta1
Projects
None yet
Development

No branches or pull requests

2 participants