elastic / elasticsearch-net

This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.
https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html
Apache License 2.0
3.54k stars 1.14k forks source link

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

Open MartinAprimo opened 3 days ago

MartinAprimo commented 3 days ago

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 commented 3 days ago

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.