-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathINavigationSearchService.cs
More file actions
58 lines (50 loc) · 1.91 KB
/
INavigationSearchService.cs
File metadata and controls
58 lines (50 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
namespace Elastic.Documentation.Search;
public interface INavigationSearchService
{
Task<NavigationSearchResponse> NavigationSearchAsync(NavigationSearchRequest request, Cancel ctx = default);
}
public record NavigationSearchRequest
{
public required string Query { get; init; }
public int PageNumber { get; init; } = 1;
public int PageSize { get; init; } = 20;
public string? TypeFilter { get; init; }
}
public record NavigationSearchResponse
{
public required IEnumerable<NavigationSearchResultItem> Results { get; init; }
public required int TotalResults { get; init; }
public required int PageNumber { get; init; }
public required int PageSize { get; init; }
public NavigationSearchAggregations Aggregations { get; init; } = new();
public int PageCount => TotalResults > 0
? (int)Math.Ceiling((double)TotalResults / PageSize)
: 0;
}
public record NavigationSearchAggregations
{
public IReadOnlyDictionary<string, long> Type { get; init; } = new Dictionary<string, long>();
}
public record NavigationSearchResult
{
public required int TotalHits { get; init; }
public required List<NavigationSearchResultItem> Results { get; init; }
public IReadOnlyDictionary<string, long> Aggregations { get; init; } = new Dictionary<string, long>();
}
public record NavigationSearchResultItemParent
{
public required string Title { get; init; }
public required string Url { get; init; }
}
public record NavigationSearchResultItem
{
public required string Type { get; init; }
public required string Url { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
public required NavigationSearchResultItemParent[] Parents { get; init; }
public float Score { get; init; }
}