@@ -9,21 +9,43 @@ namespace Nest
9
9
[ JsonObject ( MemberSerialization = MemberSerialization . OptIn ) ]
10
10
public interface IBoolQuery : IQuery
11
11
{
12
- [ JsonProperty ( "must" ) ]
12
+ /// <summary>
13
+ /// The clause(s) that must appear in matching documents
14
+ /// </summary>
15
+ [ JsonProperty ( "must" , DefaultValueHandling = DefaultValueHandling . Ignore ) ]
13
16
IEnumerable < QueryContainer > Must { get ; set ; }
14
17
15
- [ JsonProperty ( "must_not" ) ]
18
+ /// <summary>
19
+ /// The clause (query) must not appear in the matching documents. Note that it is not possible to search on documents that only consists of a must_not clauses.
20
+ /// </summary>
21
+ [ JsonProperty ( "must_not" , DefaultValueHandling = DefaultValueHandling . Ignore ) ]
16
22
IEnumerable < QueryContainer > MustNot { get ; set ; }
17
23
18
- [ JsonProperty ( "should" ) ]
24
+ /// <summary>
25
+ /// The clause (query) should appear in the matching document. A boolean query with no must clauses, one or more should clauses must match a document.
26
+ /// The minimum number of should clauses to match can be set using minimum_should_match parameter.
27
+ /// </summary>
28
+ [ JsonProperty ( "should" , DefaultValueHandling = DefaultValueHandling . Ignore ) ]
19
29
IEnumerable < QueryContainer > Should { get ; set ; }
20
30
21
- [ JsonProperty ( "filter" ) ]
31
+ /// <summary>
32
+ /// The clause (query) which is to be used as a filter (in filter context).
33
+ /// </summary>
34
+ [ JsonProperty ( "filter" , DefaultValueHandling = DefaultValueHandling . Ignore ) ]
22
35
IEnumerable < QueryContainer > Filter { get ; set ; }
23
36
37
+ /// <summary>
38
+ /// Specifies a minimum number of the optional BooleanClauses which must be satisfied.
39
+ /// </summary>
24
40
[ JsonProperty ( "minimum_should_match" ) ]
25
41
MinimumShouldMatch MinimumShouldMatch { get ; set ; }
26
42
43
+ /// <summary>
44
+ /// Specifies if the coordination factor for the query should be disabled.
45
+ /// The coordination factor is used to reward documents that contain a higher
46
+ /// percentage of the query terms. The more query terms that appear in the document,
47
+ /// the greater the chances that the document is a good match for the query.
48
+ /// </summary>
27
49
[ JsonProperty ( "disable_coord" ) ]
28
50
bool ? DisableCoord { get ; set ; }
29
51
@@ -35,11 +57,38 @@ public class BoolQuery : QueryBase, IBoolQuery
35
57
internal static bool Locked ( IBoolQuery q ) => ! q . Name . IsNullOrEmpty ( ) || q . Boost . HasValue || q . DisableCoord . HasValue || q . MinimumShouldMatch != null ;
36
58
bool IBoolQuery . Locked => BoolQuery . Locked ( this ) ;
37
59
60
+ /// <summary>
61
+ /// The clause(s) that must appear in matching documents
62
+ /// </summary>
38
63
public IEnumerable < QueryContainer > Must { get ; set ; }
64
+
65
+ /// <summary>
66
+ /// The clause (query) must not appear in the matching documents. Note that it is not possible to search on documents that only consists of a must_not clauses.
67
+ /// </summary>
39
68
public IEnumerable < QueryContainer > MustNot { get ; set ; }
69
+
70
+ /// <summary>
71
+ /// The clause (query) should appear in the matching document. A boolean query with no must clauses, one or more should clauses must match a document.
72
+ /// The minimum number of should clauses to match can be set using minimum_should_match parameter.
73
+ /// </summary>
40
74
public IEnumerable < QueryContainer > Should { get ; set ; }
75
+
76
+ /// <summary>
77
+ /// The clause (query) which is to be used as a filter (in filter context).
78
+ /// </summary>
41
79
public IEnumerable < QueryContainer > Filter { get ; set ; }
80
+
81
+ /// <summary>
82
+ /// Specifies a minimum number of the optional BooleanClauses which must be satisfied.
83
+ /// </summary>
42
84
public MinimumShouldMatch MinimumShouldMatch { get ; set ; }
85
+
86
+ /// <summary>
87
+ /// Specifies if the coordination factor for the query should be disabled.
88
+ /// The coordination factor is used to reward documents that contain a higher
89
+ /// percentage of the query terms. The more query terms that appear in the document,
90
+ /// the greater the chances that the document is a good match for the query.
91
+ /// </summary>
43
92
public bool ? DisableCoord { get ; set ; }
44
93
45
94
internal override void WrapInContainer ( IQueryContainer c ) => c . Bool = this ;
@@ -50,10 +99,10 @@ internal static bool IsConditionless(IBoolQuery q)
50
99
if ( ! q . Must . HasAny ( ) && ! q . Should . HasAny ( ) && ! q . MustNot . HasAny ( ) && ! q . Filter . HasAny ( ) )
51
100
return true ;
52
101
53
- var mustNots = q . MustNot . HasAny ( ) && q . MustNot . All ( qq => qq . IsConditionless ) ;
54
- var shoulds = q . Should . HasAny ( ) && q . Should . All ( qq => qq . IsConditionless ) ;
55
- var musts = q . Must . HasAny ( ) && q . Must . All ( qq => qq . IsConditionless ) ;
56
- var filters = q . Filter . HasAny ( ) && q . Filter . All ( qq => qq . IsConditionless ) ;
102
+ var mustNots = q . MustNot . HasAny ( ) && q . MustNot . All ( qq => qq . IsConditionless ( ) ) ;
103
+ var shoulds = q . Should . HasAny ( ) && q . Should . All ( qq => qq . IsConditionless ( ) ) ;
104
+ var musts = q . Must . HasAny ( ) && q . Must . All ( qq => qq . IsConditionless ( ) ) ;
105
+ var filters = q . Filter . HasAny ( ) && q . Filter . All ( qq => qq . IsConditionless ( ) ) ;
57
106
58
107
return mustNots && shoulds && musts && filters ;
59
108
}
@@ -64,7 +113,7 @@ public class BoolQueryDescriptor<T>
64
113
, IBoolQuery where T : class
65
114
{
66
115
bool IBoolQuery . Locked => BoolQuery . Locked ( this ) ;
67
-
116
+
68
117
protected override bool Conditionless => BoolQuery . IsConditionless ( this ) ;
69
118
IEnumerable < QueryContainer > IBoolQuery . Must { get ; set ; }
70
119
IEnumerable < QueryContainer > IBoolQuery . MustNot { get ; set ; }
@@ -73,6 +122,13 @@ public class BoolQueryDescriptor<T>
73
122
MinimumShouldMatch IBoolQuery . MinimumShouldMatch { get ; set ; }
74
123
bool ? IBoolQuery . DisableCoord { get ; set ; }
75
124
125
+ /// <summary>
126
+ /// Specifies if the coordination factor for the query should be disabled.
127
+ /// The coordination factor is used to reward documents that contain a higher
128
+ /// percentage of the query terms. The more query terms that appear in the document,
129
+ /// the greater the chances that the document is a good match for the query.
130
+ /// </summary>
131
+ /// <returns></returns>
76
132
public BoolQueryDescriptor < T > DisableCoord ( ) => Assign ( a => a . DisableCoord = true ) ;
77
133
78
134
/// <summary>
@@ -97,7 +153,8 @@ public BoolQueryDescriptor<T> Must(IEnumerable<Func<QueryContainerDescriptor<T>,
97
153
/// <summary>
98
154
/// The clause(s) that must appear in matching documents
99
155
/// </summary>
100
- public BoolQueryDescriptor < T > Must ( params QueryContainer [ ] queries ) => Assign ( a => a . Must = queries . Where ( q => ! q . IsNullOrConditionless ( ) ) . ToListOrNullIfEmpty ( ) ) ;
156
+ public BoolQueryDescriptor < T > Must ( params QueryContainer [ ] queries ) =>
157
+ Assign ( a => a . Must = queries . Where ( q => ! q . IsNullOrConditionless ( ) ) . ToListOrNullIfEmpty ( ) ) ;
101
158
102
159
/// <summary>
103
160
/// The clause (query) must not appear in the matching documents. Note that it is not possible to search on documents that only consists of a must_not clauses.
@@ -120,7 +177,8 @@ public BoolQueryDescriptor<T> MustNot(IEnumerable<Func<QueryContainerDescriptor<
120
177
/// </summary>
121
178
/// <param name="queries"></param>
122
179
/// <returns></returns>
123
- public BoolQueryDescriptor < T > MustNot ( params QueryContainer [ ] queries ) => Assign ( a => a . MustNot = queries . Where ( q => ! q . IsNullOrConditionless ( ) ) . ToListOrNullIfEmpty ( ) ) ;
180
+ public BoolQueryDescriptor < T > MustNot ( params QueryContainer [ ] queries ) =>
181
+ Assign ( a => a . MustNot = queries . Where ( q => ! q . IsNullOrConditionless ( ) ) . ToListOrNullIfEmpty ( ) ) ;
124
182
125
183
/// <summary>
126
184
/// The clause (query) should appear in the matching document. A boolean query with no must clauses, one or more should clauses must match a document.
@@ -146,7 +204,8 @@ public BoolQueryDescriptor<T> Should(IEnumerable<Func<QueryContainerDescriptor<T
146
204
/// </summary>
147
205
/// <param name="queries"></param>
148
206
/// <returns></returns>
149
- public BoolQueryDescriptor < T > Should ( params QueryContainer [ ] queries ) => Assign ( a => a . Should = queries . Where ( q => ! q . IsNullOrConditionless ( ) ) . ToListOrNullIfEmpty ( ) ) ;
207
+ public BoolQueryDescriptor < T > Should ( params QueryContainer [ ] queries ) =>
208
+ Assign ( a => a . Should = queries . Where ( q => ! q . IsNullOrConditionless ( ) ) . ToListOrNullIfEmpty ( ) ) ;
150
209
151
210
/// <summary>
152
211
/// The clause (query) which is to be used as a filter (in filter context).
@@ -169,6 +228,7 @@ public BoolQueryDescriptor<T> Filter(IEnumerable<Func<QueryContainerDescriptor<T
169
228
/// </summary>
170
229
/// <param name="queries"></param>
171
230
/// <returns></returns>
172
- public BoolQueryDescriptor < T > Filter ( params QueryContainer [ ] queries ) => Assign ( a => a . Filter = queries . Where ( q => ! q . IsNullOrConditionless ( ) ) . ToListOrNullIfEmpty ( ) ) ;
231
+ public BoolQueryDescriptor < T > Filter ( params QueryContainer [ ] queries ) =>
232
+ Assign ( a => a . Filter = queries . Where ( q => ! q . IsNullOrConditionless ( ) ) . ToListOrNullIfEmpty ( ) ) ;
173
233
}
174
234
}
0 commit comments