elastic/elasticsearch-net-example

SwapAlias fails second time on 6.x-codecomplete-netcore

matbarker opened this issue · 4 comments

Steps to Reproduce:

Clone the repository and run it, stop it, run it again.

NuSearch.Indexer.Program.SwapAlias() {...} fails on the call to Client.Alias(...);

with the message:

Invalid NEST response built from a unsuccessful low level call on POST: /_aliases
# Audit trail of this API call:
 - [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.0233763
# OriginalException: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. ServerError: Type: illegal_argument_exception Reason: "The provided expression [nusearch] matches an alias, specify the corresponding concrete indices instead."

Version

Running ElasticSearch v 6.3.0

I was going through the directions on 6.x-netcore and ran into the same issue. I solved it by changing the line:

aliases.Add(a => a.Alias(NuSearchConfiguration.OldIndexAlias).Index(NuSearchConfiguration.LiveIndexAlias));

to:

aliases.Add(a => a.Alias(NuSearchConfiguration.OldIndexAlias).Index(Client.GetIndicesPointingToAlias(NuSearchConfiguration.LiveIndexAlias).First()));

Thanks @ccoulson. Would you mind submitting a PR with the change?

Done!

#31 is now merged into 6.x and 7.x so closing this.