diff --git a/src/SJZY.Track.Repository/Repositories/TrackDetailsEsRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackDetailsEsRepository.cs index e6415867..588a3bd7 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackDetailsEsRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackDetailsEsRepository.cs @@ -1,7 +1,9 @@ using Nest; using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Expand.ElasticSearch.Services; +using SJZY.Track.Domain.Aggregates.OrderAggregate; using SJZY.Track.Domain.Aggregates.TrackDetailsAggregate; +using SJZY.Track.Domain.Aggregates.TrackPushAggregate; using SJZY.Track.Domain.Consts; using SJZY.Track.Domain.Dtos.TrackDetails; using SJZY.Track.Domain.Enums; @@ -851,12 +853,35 @@ public class TrackDetailsEsRepository : ElasticSearchContextAbstract(m => m - .AutoMap()); - //字段迁移,isVisibility => isExternal - await Context.UpdateByQueryAsync(u => u - .Query(q => q.MatchAll()) - .Script(s => s.Source("ctx._source.isExternal = ctx._source.isVisibility")) + var indexName1 = $"{GlobalConst.TrackDetailsIndex}-{DateTime.Now:yyyy.MM.dd}"; + var indexName2 = $"{GlobalConst.TrackPushRecordIndex}-{DateTime.Now:yyyy.MM.dd}"; + var indexName3 = $"{GlobalConst.OrderOperationRecordIndex}-{DateTime.Now:yyyy.MM.dd}"; + + var exists1 = await Context.Indices.ExistsAsync(indexName1); + if (!exists1.Exists) + { + await Context.Indices.CreateAsync(indexName1); + await Context.MapAsync(m => m.Index(indexName1).AutoMap()); + } + + var exists2 = await Context.Indices.ExistsAsync(indexName2); + if (!exists2.Exists) + { + await Context.Indices.CreateAsync(indexName2); + await Context.MapAsync(m => m.Index(indexName2).AutoMap()); + } + + var exists3 = await Context.Indices.ExistsAsync(indexName3); + if (!exists3.Exists) + { + await Context.Indices.CreateAsync(indexName3); + await Context.MapAsync(m => m.Index(indexName3).AutoMap()); + } + + var r = await Context.Indices.BulkAliasAsync(b => + b.Add(a => a.Alias(GlobalConst.TrackDetailsIndex).Index(indexName1)) + .Add(a => a.Alias(GlobalConst.TrackPushRecordIndex).Index(indexName2)) + .Add(a => a.Alias(GlobalConst.OrderOperationRecordIndex).Index(indexName3)) ); } }