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

Removing an single alias for indices throws 404 index not found #8255

Open
MartinAprimo opened this issue Jul 4, 2024 · 4 comments
Open

Comments

@MartinAprimo
Copy link

MartinAprimo commented Jul 4, 2024

Elastic.Clients.Elasticsearch version: 8.14.4

Elasticsearch version: 8.8.2

.NET runtime version: .NET Framework 4.8.9241.0

Operating system version: Win 11

Description of the problem including expected versus actual behavior: When I try to remove an alias from multiple indices at once in a single remove action, the "Indices" property is converted to a comma separated list instead of an array with index names.
When I catch the request it looks like:

POST /_aliases
{
"actions": [
...
{
"remove": {
"alias": "tenant-1_unittests",
"indices": "tenant-1_unittests_classification_v1,tenant-1_unittests_suggestion_v1,tenant-1_unittests_record_v1"
}
}
]
}

Steps to reproduce:
Code sample is
var actions = new IndexUpdateAliasesAction[] {
IndexUpdateAliasesAction.Add(new AddAction(){Alias = Tenant, Index = RecordIndexName(newVersion)}),
IndexUpdateAliasesAction.Add(new AddAction(){Alias = Tenant, Index = ClassificationIndexName(newVersion)}),
IndexUpdateAliasesAction.Add(new AddAction(){Alias = Tenant, Index = SuggestionIndexName(newVersion)}),

	IndexUpdateAliasesAction.Add(new AddAction(){Alias = RecordAlias, Index = RecordIndexName(newVersion)}),
	IndexUpdateAliasesAction.Add(new AddAction(){Alias = ClassificationAlias, Index = ClassificationIndexName(newVersion)}),
	IndexUpdateAliasesAction.Add(new AddAction(){Alias = SuggestionAlias, Index = SuggestionIndexName(newVersion)})

};

if(deprecatedIndexNames != null && deprecatedIndexNames.Any())
{
var indicesNames = Indices.Parse(string.Join(",", deprecatedIndexNames));
actions = actions.Concat(new IndexUpdateAliasesAction[] { IndexUpdateAliasesAction.Remove(new RemoveAction() { Alias = Tenant, Indices = indicesNames }) }).ToArray();
}

var response = await _elasticClient.Indices.UpdateAliasesAsync(new UpdateAliasesRequest()
{
Actions = actions
}, cancellationToken).ConfigureAwait(false);

Expected behavior
The request should (I believe) look like:
POST /_aliases
{
"actions": [
...
{
"remove": {
"alias": "tenant-1_unittests",
"indices": ["tenant-1_unittests_classification_v1","tenant-1_unittests_suggestion_v1","tenant-1_unittests_record_v1"]
}
}
]
}

When I try this, it seems to work OK.

I probably can work around this by adding multiple remove actions.

Provide ConnectionSettings (if relevant):

Provide DebugInformation (if relevant):

@flobernd
Copy link
Member

flobernd commented Jul 4, 2024

Some endpoints require multiple indices to be sent as a comma separated list, like e.g.

Other ones only accept arrays, like e.g.:

We must model these semantics in the specification to generate custom serializationn logic.

@cguedel
Copy link

cguedel commented Jul 9, 2024

We've ran into the same problem. Can you give a rough estimate on when this can be fixed?

@flobernd
Copy link
Member

flobernd commented Jul 9, 2024

@cguedel The preferred solution affects all language clients (as it must be fixed in the specification) and requires careful planning. We had an initial brainstorming regarding this issue, but large parts of the team (including me) is on PTO or will be on PTO this month, so please don't expect an immediate fix.

In the meantime, this issue can be worked around by using multiple actions with a single index name instead of a single action with multiple index names.

@cguedel
Copy link

cguedel commented Jul 9, 2024

I see, thanks! We'll use the workaround for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants