Browse Source
Merge pull request #1557 from colinin/es-index
fix: Fix the reversed sorting order
pull/1467/merge
yx lin
1 month ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
33 additions and
5 deletions
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/LINGYUN/Abp/AuditLogging/Elasticsearch/AuditLoggingIndexInitializer.cs
-
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/LINGYUN/Abp/AuditLogging/Elasticsearch/ElasticsearchAuditLogManager.cs
-
aspnet-core/framework/elasticsearch/LINGYUN.Abp.Elasticsearch/Elastic/Clients/Elasticsearch/SortOptionsExtenssions.cs
-
aspnet-core/framework/elasticsearch/LINGYUN.Abp.Elasticsearch/LINGYUN/Abp/Elasticsearch/ExpressionQueryService.cs
-
aspnet-core/framework/logging/LINGYUN.Abp.Logging.Serilog.Elasticsearch/LINGYUN/Abp/AuditLogging/Serilog/Elasticsearch/SerilogElasticsearchLoggingManager.cs
|
|
|
@ -1,12 +1,10 @@ |
|
|
|
using Elastic.Clients.Elasticsearch; |
|
|
|
using Elastic.Clients.Elasticsearch.Mapping; |
|
|
|
using Elastic.Transport.Products.Elasticsearch; |
|
|
|
using LINGYUN.Abp.Elasticsearch; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Logging.Abstractions; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using System; |
|
|
|
using System.Text; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp; |
|
|
|
|
|
|
|
@ -526,7 +526,7 @@ public class ElasticsearchAuditLogManager : IAuditLogManager, ITransientDependen |
|
|
|
dsl => dsl.Indices(indexName) |
|
|
|
.Query(query) |
|
|
|
// 反转排序取第一个数据作为起始索引
|
|
|
|
.Sort(sorts.Select(x => x).Reverse().ToArray()) |
|
|
|
.Sort(sorts.ReverseSort()!.ToArray()) |
|
|
|
.SourceIncludes(x => x.Id) |
|
|
|
.SearchAfter(firstHit.Sort.ToList()) |
|
|
|
.Size(1), |
|
|
|
|
|
|
|
@ -0,0 +1,30 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
namespace Elastic.Clients.Elasticsearch; |
|
|
|
|
|
|
|
public static class SortOptionsExtenssions |
|
|
|
{ |
|
|
|
public static IEnumerable<SortOptions>? ReverseSort(this IEnumerable<SortOptions>? sortOptions) |
|
|
|
{ |
|
|
|
if (sortOptions == null) |
|
|
|
{ |
|
|
|
return sortOptions; |
|
|
|
} |
|
|
|
var newSort = sortOptions.Select(sort => |
|
|
|
{ |
|
|
|
if (sort.Field != null) |
|
|
|
{ |
|
|
|
sort.Field.Order = sort.Field.Order == SortOrder.Asc |
|
|
|
? SortOrder.Desc |
|
|
|
: SortOrder.Asc; |
|
|
|
} |
|
|
|
return sort; |
|
|
|
}).ToArray(); |
|
|
|
|
|
|
|
newSort.Reverse(); |
|
|
|
|
|
|
|
return newSort; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -246,7 +246,7 @@ public class ExpressionQueryService : IExpressionQueryService, ITransientDepende |
|
|
|
dsl => dsl.Indices(indexName) |
|
|
|
.Query(query) |
|
|
|
// 反转排序取第一个数据作为起始索引
|
|
|
|
.Sort(sorts.Select(x => x).Reverse().ToArray()) |
|
|
|
.Sort(sorts.ReverseSort()!.ToArray()) |
|
|
|
.SourceIncludes([]) |
|
|
|
.SearchAfter(firstHit.Sort.ToList()) |
|
|
|
.Size(1), |
|
|
|
|
|
|
|
@ -579,7 +579,7 @@ public class SerilogElasticsearchLoggingManager : ILoggingManager, ISingletonDep |
|
|
|
dsl => dsl.Indices(CreateIndex()) |
|
|
|
.Query(query) |
|
|
|
// 反转排序取第一个数据作为起始索引
|
|
|
|
.Sort(sorts.Select(x => x).Reverse().ToArray()) |
|
|
|
.Sort(sorts.ReverseSort()!.ToArray()) |
|
|
|
.SourceIncludes(x => x.Level) |
|
|
|
.SearchAfter(firstHit.Sort.ToList()) |
|
|
|
.Size(1), |
|
|
|
|