From fee07688536c06e3ea79afa5d7ab10cfa5b3952f Mon Sep 17 00:00:00 2001 From: hardstylewyl <827778732@qq.com> Date: Mon, 16 Jun 2025 14:58:13 +0800 Subject: [PATCH] =?UTF-8?q?update:=E8=B0=83=E6=95=B4=E8=BD=A8=E8=BF=B9?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=95=B0=E6=8D=AE=E7=9A=84ES=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/TrackDetailsEsRepository.cs | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) 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)) ); } }