Skip to content

Commit 4073686

Browse files
committed
Merge pull request #1241 from jekstrom/develop
Add support for lenient property for multi match query.
2 parents 551213c + ef59a33 commit 4073686

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Nest/DSL/Query/MultiMatchQueryDescriptor.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public interface IMultiMatchQuery : IQuery
4444
[JsonProperty(PropertyName = "boost")]
4545
double? Boost { get; set; }
4646

47+
[JsonProperty(PropertyName = "lenient")]
48+
bool? Lenient { get; set; }
49+
4750
[JsonProperty(PropertyName = "use_dis_max")]
4851
bool? UseDisMax { get; set; }
4952

@@ -79,6 +82,7 @@ protected override void WrapInContainer(IQueryContainer container)
7982
public int? MaxExpansions { get; set; }
8083
public int? Slop { get; set; }
8184
public double? Boost { get; set; }
85+
public bool? Lenient { get; set; }
8286
public bool? UseDisMax { get; set; }
8387
public double? TieBreaker { get; set; }
8488
public string MinimumShouldMatch { get; set; }
@@ -109,6 +113,8 @@ public class MultiMatchQueryDescriptor<T> : IMultiMatchQuery where T : class
109113

110114
double? IMultiMatchQuery.Boost { get; set; }
111115

116+
bool? IMultiMatchQuery.Lenient { get; set; }
117+
112118
bool? IMultiMatchQuery.UseDisMax { get; set; }
113119

114120
double? IMultiMatchQuery.TieBreaker { get; set; }
@@ -193,6 +199,12 @@ public MultiMatchQueryDescriptor<T> Boost(double boost)
193199
((IMultiMatchQuery)this).Boost = boost;
194200
return this;
195201
}
202+
203+
public MultiMatchQueryDescriptor<T> Lenient(bool lenient = true) {
204+
((IMultiMatchQuery)this).Lenient = lenient;
205+
return this;
206+
}
207+
196208
public MultiMatchQueryDescriptor<T> PrefixLength(int prefixLength)
197209
{
198210
((IMultiMatchQuery)this).PrefixLength = prefixLength;

src/Tests/Nest.Tests.Unit/QueryParsers/Queries/MultiMatchQueryTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public void MultiMatch_Deserializes()
1414
f=>f.MultiMatch(mq=>mq
1515
.Analyzer("my-analyzer")
1616
.Boost(2.5)
17+
.Lenient()
1718
.CutoffFrequency(0.8)
1819
.Fuzziness(0.8)
1920
.MaxExpansions(2)
@@ -29,6 +30,7 @@ public void MultiMatch_Deserializes()
2930
);
3031
q.Analyzer.Should().Be("my-analyzer");
3132
q.Boost.Should().Be(2.5);
33+
q.Lenient.Should().BeTrue();
3234
q.CutoffFrequency.Should().Be(0.8);
3335
q.Fuzziness.Should().Be(0.8);
3436
q.MaxExpansions.Should().Be(2);

0 commit comments

Comments
 (0)