4
4
5
5
namespace Nest
6
6
{
7
+ /// <summary>
8
+ /// Allows to add one or more sort on specific fields.
9
+ /// </summary>
7
10
[ JsonObject ( MemberSerialization = MemberSerialization . OptIn ) ]
8
11
[ ContractJsonConverter ( typeof ( SortJsonConverter ) ) ]
9
12
public interface ISort
10
13
{
14
+ /// <summary>
15
+ /// The field to sort on
16
+ /// </summary>
11
17
Field SortKey { get ; }
12
18
13
- [ JsonProperty ( "missing" ) ]
19
+ /// <summary>
20
+ /// Specifies how docs which are missing the field should be treated
21
+ /// </summary>
22
+ [ JsonIgnore ]
23
+ [ Obsolete ( "Use MissingValue" ) ]
14
24
string Missing { get ; set ; }
15
25
26
+ /// <summary>
27
+ /// Specifies how docs which are missing the field should be treated
28
+ /// </summary>
29
+ [ JsonProperty ( "missing" ) ]
30
+ object MissingValue { get ; set ; }
31
+
32
+ /// <summary>
33
+ /// The sort order
34
+ /// </summary>
16
35
[ JsonProperty ( "order" ) ]
17
36
SortOrder ? Order { get ; set ; }
18
37
38
+ /// <summary>
39
+ /// Elasticsearch supports sorting by array or multi-valued fields. <see cref="Mode"/>
40
+ /// controls what array value is picked for sorting the document it belongs to.
41
+ /// </summary>
19
42
[ JsonProperty ( "mode" ) ]
20
43
SortMode ? Mode { get ; set ; }
21
44
45
+ /// <summary>
46
+ /// A filter that the inner objects inside the nested path should match with in order for its field values
47
+ /// to be taken into account by sorting.
48
+ /// Common case is to repeat the query / filter inside the nested filter or query.
49
+ /// </summary>
22
50
[ JsonProperty ( "nested_filter" ) ]
23
51
QueryContainer NestedFilter { get ; set ; }
24
52
53
+ /// <summary>
54
+ /// Defines on which nested object to sort. The actual sort field must be a direct field inside
55
+ /// this nested object. When sorting by nested field, this field is mandatory.
56
+ /// </summary>
25
57
[ JsonProperty ( "nested_path" ) ]
26
58
Field NestedPath { get ; set ; }
27
59
}
28
60
61
+ /// <inheritdoc/>
29
62
public abstract class SortBase : ISort
30
63
{
31
- public string Missing { get ; set ; }
64
+ /// <inheritdoc/>
65
+ [ Obsolete ( "Use MissingValue" ) ]
66
+ public string Missing
67
+ {
68
+ get => MissingValue as string ;
69
+ set => MissingValue = value ;
70
+ }
71
+ /// <inheritdoc/>
72
+ public object MissingValue { get ; set ; }
73
+ /// <inheritdoc/>
32
74
public SortOrder ? Order { get ; set ; }
75
+ /// <inheritdoc/>
33
76
public SortMode ? Mode { get ; set ; }
77
+ /// <inheritdoc/>
34
78
public QueryContainer NestedFilter { get ; set ; }
79
+ /// <inheritdoc/>
35
80
public Field NestedPath { get ; set ; }
81
+ /// <inheritdoc/>
36
82
Field ISort . SortKey => this . SortKey ;
83
+ /// <summary>
84
+ /// The field to sort on
85
+ /// </summary>
37
86
protected abstract Field SortKey { get ; }
38
87
}
39
88
40
- public abstract class SortDescriptorBase < TDescriptor , TInterface , T > : DescriptorBase < TDescriptor , TInterface > , ISort
41
- where T : class
89
+ public abstract class SortDescriptorBase < TDescriptor , TInterface , T > : DescriptorBase < TDescriptor , TInterface > , ISort
90
+ where T : class
42
91
where TDescriptor : SortDescriptorBase < TDescriptor , TInterface , T > , TInterface , ISort
43
92
where TInterface : class , ISort
44
93
{
45
94
Field ISort . SortKey => this . SortKey ;
46
95
47
- string ISort . Missing { get ; set ; }
96
+ [ Obsolete ( "Use MissingValue" ) ]
97
+ string ISort . Missing
98
+ {
99
+ get => Self . MissingValue as string ;
100
+ set => Self . MissingValue = value ;
101
+ }
102
+
103
+ object ISort . MissingValue { get ; set ; }
48
104
49
105
SortOrder ? ISort . Order { get ; set ; }
50
106
@@ -71,11 +127,12 @@ public virtual TDescriptor NestedFilter(Func<QueryContainerDescriptor<T>, QueryC
71
127
72
128
public virtual TDescriptor NestedPath ( Expression < Func < T , object > > objectPath ) => Assign ( a => a . NestedPath = objectPath ) ;
73
129
74
- public virtual TDescriptor MissingLast ( ) => Assign ( a => a . Missing = "_last" ) ;
130
+ public virtual TDescriptor MissingLast ( ) => Assign ( a => a . MissingValue = "_last" ) ;
75
131
76
- public virtual TDescriptor MissingFirst ( ) => Assign ( a => a . Missing = "_first" ) ;
132
+ public virtual TDescriptor MissingFirst ( ) => Assign ( a => a . MissingValue = "_first" ) ;
77
133
78
- public virtual TDescriptor MissingValue ( string value ) => Assign ( a => a . Missing = value ) ;
134
+ public virtual TDescriptor MissingValue ( string value ) => Assign ( a => a . MissingValue = value ) ;
79
135
136
+ public virtual TDescriptor Missing ( object value ) => Assign ( a => a . MissingValue = value ) ;
80
137
}
81
- }
138
+ }
0 commit comments