Skip to content

Commit a684be9

Browse files
committed
Fix #3325 Add support for zero_terms_query to match_phrase query (#3363)
(cherry picked from commit 93400ac)
1 parent 56109cf commit a684be9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Nest/QueryDsl/FullText/MatchPhrasePrefix/MatchPhrasePrefixQuery.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ public interface IMatchPhrasePrefixQuery : IFieldNameQuery
1818

1919
[JsonProperty("slop")]
2020
int? Slop { get; set; }
21+
22+
/// <summary>
23+
/// If the analyzer used removes all tokens in a query like a stop filter does, the default behavior is
24+
/// to match no documents at all. In order to change that, <see cref="ZeroTermsQuery"/> can be used,
25+
/// which accepts <see cref="ZeroTermsQuery.None"/> (default) and <see cref="ZeroTermsQuery.All"/>
26+
/// which corresponds to a match_all query.
27+
/// </summary>
28+
[JsonProperty("zero_terms_query")]
29+
ZeroTermsQuery? ZeroTermsQuery { get; set; }
2130
}
2231

2332
public class MatchPhrasePrefixQuery : FieldNameQueryBase, IMatchPhrasePrefixQuery
@@ -28,6 +37,8 @@ public class MatchPhrasePrefixQuery : FieldNameQueryBase, IMatchPhrasePrefixQuer
2837
public int? MaxExpansions { get; set; }
2938
public string Query { get; set; }
3039
public int? Slop { get; set; }
40+
/// <inheritdoc />
41+
public ZeroTermsQuery? ZeroTermsQuery { get; set; }
3142

3243
internal override void InternalWrapInContainer(IQueryContainer c) => c.MatchPhrasePrefix = this;
3344

@@ -44,6 +55,7 @@ public class MatchPhrasePrefixQueryDescriptor<T>
4455
string IMatchPhrasePrefixQuery.Analyzer { get; set; }
4556
int? IMatchPhrasePrefixQuery.MaxExpansions { get; set; }
4657
int? IMatchPhrasePrefixQuery.Slop { get; set; }
58+
ZeroTermsQuery? IMatchPhrasePrefixQuery.ZeroTermsQuery { get; set; }
4759

4860
public MatchPhrasePrefixQueryDescriptor<T> Query(string query) => Assign(a => a.Query = query);
4961

@@ -52,5 +64,9 @@ public class MatchPhrasePrefixQueryDescriptor<T>
5264
public MatchPhrasePrefixQueryDescriptor<T> MaxExpansions(int? maxExpansions) => Assign(a => a.MaxExpansions = maxExpansions);
5365

5466
public MatchPhrasePrefixQueryDescriptor<T> Slop(int? slop) => Assign(a => a.Slop = slop);
67+
68+
/// <inheritdoc cref="IMatchQuery.ZeroTermsQuery" />
69+
public MatchPhrasePrefixQueryDescriptor<T> ZeroTermsQuery(ZeroTermsQuery? zeroTermsQuery) => Assign(a => a.ZeroTermsQuery = zeroTermsQuery);
70+
5571
}
5672
}

0 commit comments

Comments
 (0)