elasticsearch-net icon indicating copy to clipboard operation
elasticsearch-net copied to clipboard

Removing an single alias for indices throws 404 index not found

Open MartinAprimo opened this issue 7 months ago • 4 comments

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):

MartinAprimo avatar Jul 04 '24 11:07 MartinAprimo