Skip to content

Commit a398f0e

Browse files
committed
fix #741 missing minimum_should_match on match queries
1 parent 0a97e77 commit a398f0e

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

Diff for: src/Nest/DSL/Query/MatchPhrasePrefixQueryDescriptor.cs

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text;
5-
using Newtonsoft.Json;
6-
using Newtonsoft.Json.Converters;
7-
using System.Linq.Expressions;
85

96
namespace Nest
107
{

Diff for: src/Nest/DSL/Query/MatchQueryDescriptor.cs

+40-16
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public interface IMatchQuery : IFieldNameQuery
5050
[JsonProperty(PropertyName = "lenient")]
5151
bool? Lenient { get; set; }
5252

53+
[JsonProperty("minimum_should_match")]
54+
string MinimumShouldMatch { get; set; }
55+
5356
[JsonProperty(PropertyName = "operator")]
5457
[JsonConverter(typeof (StringEnumConverter))]
5558
Operator? Operator { get; set; }
@@ -86,6 +89,7 @@ void IFieldNameQuery.SetFieldName(string fieldName)
8689
public int? Slop { get; set; }
8790
public double? Boost { get; set; }
8891
public bool? Lenient { get; set; }
92+
public string MinimumShouldMatch { get; set; }
8993
public Operator? Operator { get; set; }
9094
public PropertyPathMarker Field { get; set; }
9195
}
@@ -96,12 +100,16 @@ public class MatchQueryDescriptor<T> : IMatchQuery where T : class
96100
{
97101
protected virtual string _type { get { return null; } }
98102

103+
private IMatchQuery Self { get { return this; } }
104+
99105
string IMatchQuery.Type { get { return _type; } }
100106

101107
string IMatchQuery.Query { get; set; }
102108

103109
string IMatchQuery.Analyzer { get; set; }
104110

111+
string IMatchQuery.MinimumShouldMatch { get; set; }
112+
105113
RewriteMultiTerm? IMatchQuery.Rewrite { get; set; }
106114

107115
double? IMatchQuery.Fuzziness { get; set; }
@@ -126,85 +134,101 @@ bool IQuery.IsConditionless
126134
{
127135
get
128136
{
129-
return ((IMatchQuery)this).Field.IsConditionless() || ((IMatchQuery)this).Query.IsNullOrEmpty();
137+
return Self.Field.IsConditionless() || Self.Query.IsNullOrEmpty();
130138
}
131139
}
132140
void IFieldNameQuery.SetFieldName(string fieldName)
133141
{
134-
((IMatchQuery)this).Field = fieldName;
142+
Self.Field = fieldName;
135143
}
136144
PropertyPathMarker IFieldNameQuery.GetFieldName()
137145
{
138-
return ((IMatchQuery)this).Field;
146+
return Self.Field;
139147
}
140148

141149
public MatchQueryDescriptor<T> OnField(string field)
142150
{
143-
((IMatchQuery)this).Field = field;
151+
Self.Field = field;
144152
return this;
145153
}
154+
146155
public MatchQueryDescriptor<T> OnField(Expression<Func<T, object>> objectPath)
147156
{
148-
((IMatchQuery)this).Field = objectPath;
157+
Self.Field = objectPath;
149158
return this;
150159
}
151160

152161
public MatchQueryDescriptor<T> Query(string query)
153162
{
154-
((IMatchQuery)this).Query = query;
163+
Self.Query = query;
155164
return this;
156165
}
166+
157167
public MatchQueryDescriptor<T> Lenient(bool lenient = true)
158168
{
159-
((IMatchQuery)this).Lenient = lenient;
169+
Self.Lenient = lenient;
160170
return this;
161171
}
172+
162173
public MatchQueryDescriptor<T> Analyzer(string analyzer)
163174
{
164-
((IMatchQuery)this).Analyzer = analyzer;
175+
Self.Analyzer = analyzer;
165176
return this;
166177
}
178+
167179
public MatchQueryDescriptor<T> Fuzziness(double fuzziness)
168180
{
169-
((IMatchQuery)this).Fuzziness = fuzziness;
181+
Self.Fuzziness = fuzziness;
170182
return this;
171183
}
184+
172185
public MatchQueryDescriptor<T> CutoffFrequency(double cutoffFrequency)
173186
{
174-
((IMatchQuery)this).CutoffFrequency = cutoffFrequency;
187+
Self.CutoffFrequency = cutoffFrequency;
175188
return this;
176189
}
177190

178191
public MatchQueryDescriptor<T> Rewrite(RewriteMultiTerm rewrite)
179192
{
180-
((IMatchQuery)this).Rewrite = rewrite;
193+
Self.Rewrite = rewrite;
181194
return this;
182195
}
183196

184197
public MatchQueryDescriptor<T> Boost(double boost)
185198
{
186-
((IMatchQuery)this).Boost = boost;
199+
Self.Boost = boost;
187200
return this;
188201
}
202+
189203
public MatchQueryDescriptor<T> PrefixLength(int prefixLength)
190204
{
191-
((IMatchQuery)this).PrefixLength = prefixLength;
205+
Self.PrefixLength = prefixLength;
192206
return this;
193207
}
208+
194209
public MatchQueryDescriptor<T> MaxExpansions(int maxExpansions)
195210
{
196-
((IMatchQuery)this).MaxExpansions = maxExpansions;
211+
Self.MaxExpansions = maxExpansions;
197212
return this;
198213
}
214+
199215
public MatchQueryDescriptor<T> Slop(int slop)
200216
{
201-
((IMatchQuery)this).Slop = slop;
217+
Self.Slop = slop;
218+
return this;
219+
}
220+
221+
public MatchQueryDescriptor<T> MinimumShouldMatch(string minimumShouldMatch)
222+
{
223+
Self.MinimumShouldMatch = minimumShouldMatch;
202224
return this;
203225
}
226+
204227
public MatchQueryDescriptor<T> Operator(Operator op)
205228
{
206-
((IMatchQuery)this).Operator = op;
229+
Self.Operator = op;
207230
return this;
208231
}
232+
209233
}
210234
}

0 commit comments

Comments
 (0)