update:调整轨迹相关数据的ES初始化
This commit is contained in:
parent
c5695dda2f
commit
fee0768853
@ -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<TrackDetail
|
||||
|
||||
public async Task MigrateAsync()
|
||||
{
|
||||
await Context.MapAsync<TrackDetailsIndex>(m => m
|
||||
.AutoMap());
|
||||
//字段迁移,isVisibility => isExternal
|
||||
await Context.UpdateByQueryAsync<TrackDetailsIndex>(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<TrackDetailsIndex>(m => m.Index(indexName1).AutoMap());
|
||||
}
|
||||
|
||||
var exists2 = await Context.Indices.ExistsAsync(indexName2);
|
||||
if (!exists2.Exists)
|
||||
{
|
||||
await Context.Indices.CreateAsync(indexName2);
|
||||
await Context.MapAsync<TrackPushRecordIndex>(m => m.Index(indexName2).AutoMap());
|
||||
}
|
||||
|
||||
var exists3 = await Context.Indices.ExistsAsync(indexName3);
|
||||
if (!exists3.Exists)
|
||||
{
|
||||
await Context.Indices.CreateAsync(indexName3);
|
||||
await Context.MapAsync<OrderOperationRecordIndex>(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))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user