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

Deletion of old aliases during new index creation #158

Closed
purpleraven opened this issue Mar 18, 2022 · 0 comments
Closed

Deletion of old aliases during new index creation #158

purpleraven opened this issue Mar 18, 2022 · 0 comments

Comments

@purpleraven
Copy link

Expected Behavior

with default migration.strategy: alias new index will be created during migration and new alias will point on it.
But old alias not removed and in ES will be few indexes with same aliases.

in the code of ElasticSearchAdminService missed the delete logic execution. But all preparation done:

void pointAliasTo(String alias, String index, Integer version = null) {
        index = versionIndex(index, version)
        LOG.debug "Creating alias ${alias}, pointing to index ${index} ..."
        String oldIndex = indexPointedBy(alias)
        elasticSearchHelper.withElasticSearch { RestHighLevelClient client ->
            if (oldIndex && oldIndex != index) {
                LOG.debug "Index used to point to ${oldIndex}, removing ..."
                new IndicesAliasesRequest.AliasActions(IndicesAliasesRequest.AliasActions.Type.REMOVE)
                        .index(oldIndex)
                        .alias(alias)
            }
            IndicesAliasesRequest request = new IndicesAliasesRequest()
            IndicesAliasesRequest.AliasActions aliasAction =
                    new IndicesAliasesRequest.AliasActions(IndicesAliasesRequest.AliasActions.Type.ADD)
                            .index(index)
                            .alias(alias)
            request.addAliasAction(aliasAction)
            LOG.debug "Create alias -> index: ${index}; alias: ${alias}"
            client.indices().updateAliases(request, RequestOptions.DEFAULT)
        }
    }

AliasActions created but not executed. Is a mistake of expected behaviour?
In case of mistake I can provide a PR with a fix

Actual Behaviour

No response

Steps To Reproduce

No response

Environment Information

Version of plugin 3.0.0-snapshot

Example Application

No response

Version

4

purpleraven added a commit to purpleraven/elasticsearch-grails-plugin that referenced this issue Apr 3, 2022
remove old alias during new index with alias creation
puneetbehl pushed a commit that referenced this issue May 8, 2022
remove old alias during new index with alias creation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant