Skip to content

Commit c59d7b9

Browse files
committed
Support for minimum_should_match option on query_string_query #1356
1 parent 1808005 commit c59d7b9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Nest/DSL/Query/SimpleQueryStringQueryDescriptor.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public interface ISimpleQueryStringQuery : IQuery
3636

3737
[JsonProperty(PropertyName = "locale")]
3838
string Locale { get; set; }
39+
40+
[JsonProperty("minimum_should_match")]
41+
string MinimumShouldMatch { get; set; }
3942
}
4043

4144
public class SimpleQueryStringQuery : PlainQuery, ISimpleQueryStringQuery
@@ -54,6 +57,7 @@ protected override void WrapInContainer(IQueryContainer container)
5457
public bool? LowercaseExpendedTerms { get; set; }
5558
public string Flags { get; set; }
5659
public string Locale { get; set; }
60+
public string MinimumShouldMatch { get; set; }
5761
}
5862

5963
public class SimpleQueryStringQueryDescriptor<T> : ISimpleQueryStringQuery where T : class
@@ -75,6 +79,7 @@ public class SimpleQueryStringQueryDescriptor<T> : ISimpleQueryStringQuery where
7579
string ISimpleQueryStringQuery.Flags { get; set; }
7680

7781
string ISimpleQueryStringQuery.Locale { get; set; }
82+
string ISimpleQueryStringQuery.MinimumShouldMatch { get; set; }
7883

7984
string IQuery.Name { get; set; }
8085

@@ -159,5 +164,10 @@ public SimpleQueryStringQueryDescriptor<T> Locale(string locale)
159164
return this;
160165
}
161166

162-
}
167+
public SimpleQueryStringQueryDescriptor<T> MinimumShouldMatch(string minimumShouldMatch)
168+
{
169+
Self.MinimumShouldMatch = minimumShouldMatch;
170+
return this;
171+
}
172+
}
163173
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public void SimpleQueryString_Deserializes()
2020
.DefaultField(p=>p.Name)
2121
.OnFields(p=>p.Name, p=>p.Origin)
2222
.Query("some query")
23+
.MinimumShouldMatch("50%")
2324
)
2425
);
2526
q.Analyzer.Should().Be("my-analyzer");
@@ -30,7 +31,7 @@ public void SimpleQueryString_Deserializes()
3031
q.DefaultField.Should().Be("name");
3132
q.Fields.Should().BeEquivalentTo(new []{ "name", "origin"});
3233
q.Query.Should().Be("some query");
33-
34+
q.MinimumShouldMatch.Should().Be("50%");
3435
}
3536
}
3637
}

0 commit comments

Comments
 (0)