Skip to content

Commit e36cad4

Browse files
committed
Add documentation for fuzziness
See elastic/elasticsearch#18322
1 parent c035107 commit e36cad4

File tree

2 files changed

+46
-31
lines changed

2 files changed

+46
-31
lines changed

src/Nest/CommonOptions/Fuzziness/Fuzziness.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,15 @@ public class Fuzziness : IFuzziness
55
private bool _auto;
66
private int? _editDistance;
77
private double? _ratio;
8-
bool IFuzziness.Auto { get { return this._auto; } }
9-
int? IFuzziness.EditDistance { get { return this._editDistance; } }
10-
double? IFuzziness.Ratio { get { return this._ratio; } }
118

12-
public static Fuzziness Auto { get { return new Fuzziness() { _auto = true }; } }
9+
bool IFuzziness.Auto => this._auto;
10+
int? IFuzziness.EditDistance => this._editDistance;
11+
double? IFuzziness.Ratio => this._ratio;
1312

14-
public static Fuzziness EditDistance(int distance)
15-
{
16-
return new Fuzziness() { _editDistance = distance };
17-
}
13+
public static Fuzziness Auto => new Fuzziness { _auto = true };
1814

19-
public static Fuzziness Ratio(double ratio)
20-
{
21-
return new Fuzziness() { _ratio = ratio };
22-
}
15+
public static Fuzziness EditDistance(int distance) => new Fuzziness { _editDistance = distance };
16+
17+
public static Fuzziness Ratio(double ratio) => new Fuzziness { _ratio = ratio };
2318
}
24-
}
19+
}

src/Nest/QueryDsl/FullText/MultiMatch/MultiMatchQuery.cs

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,59 @@ namespace Nest
88
[JsonConverter(typeof(ReadAsTypeJsonConverter<MultiMatchQueryDescriptor<object>>))]
99
public interface IMultiMatchQuery : IQuery
1010
{
11-
[JsonProperty(PropertyName = "type")]
12-
[JsonConverter(typeof(StringEnumConverter))]
11+
[JsonProperty("type")]
1312
TextQueryType? Type { get; set; }
1413

15-
[JsonProperty(PropertyName = "query")]
14+
[JsonProperty("query")]
1615
string Query { get; set; }
1716

18-
[JsonProperty(PropertyName = "analyzer")]
17+
[JsonProperty("analyzer")]
1918
string Analyzer { get; set; }
2019

21-
[JsonProperty(PropertyName = "fuzzy_rewrite")]
22-
[JsonConverter(typeof(StringEnumConverter))]
20+
[JsonProperty("fuzzy_rewrite")]
2321
RewriteMultiTerm? FuzzyRewrite { get; set; }
2422

25-
[JsonProperty(PropertyName = "fuzziness")]
23+
/// <summary>
24+
/// Allows fuzzy matching based on the type of field being queried.
25+
/// Cannot be used with the
26+
/// <see cref="TextQueryType.CrossFields"/>,
27+
/// <see cref="TextQueryType.Phrase"/> or
28+
/// <see cref="TextQueryType.PhrasePrefix"/> types.
29+
/// </summary>
30+
[JsonProperty("fuzziness")]
2631
Fuzziness Fuzziness { get; set; }
2732

28-
[JsonProperty(PropertyName = "cutoff_frequency")]
33+
[JsonProperty("cutoff_frequency")]
2934
double? CutoffFrequency { get; set; }
3035

31-
[JsonProperty(PropertyName = "prefix_length")]
36+
[JsonProperty("prefix_length")]
3237
int? PrefixLength { get; set; }
3338

34-
[JsonProperty(PropertyName = "max_expansions")]
39+
[JsonProperty("max_expansions")]
3540
int? MaxExpansions { get; set; }
3641

37-
[JsonProperty(PropertyName = "slop")]
42+
[JsonProperty("slop")]
3843
int? Slop { get; set; }
3944

40-
[JsonProperty(PropertyName = "lenient")]
45+
[JsonProperty("lenient")]
4146
bool? Lenient { get; set; }
4247

43-
[JsonProperty(PropertyName = "use_dis_max")]
48+
[JsonProperty("use_dis_max")]
4449
bool? UseDisMax { get; set; }
4550

46-
[JsonProperty(PropertyName = "tie_breaker")]
51+
[JsonProperty("tie_breaker")]
4752
double? TieBreaker { get; set; }
4853

49-
[JsonProperty(PropertyName = "minimum_should_match")]
54+
[JsonProperty("minimum_should_match")]
5055
MinimumShouldMatch MinimumShouldMatch { get; set; }
5156

52-
[JsonProperty(PropertyName = "operator")]
57+
[JsonProperty("operator")]
5358
Operator? Operator { get; set; }
5459

55-
[JsonProperty(PropertyName = "fields")]
60+
[JsonProperty("fields")]
5661
Fields Fields { get; set; }
5762

58-
[JsonProperty(PropertyName = "zero_terms_query")]
63+
[JsonProperty("zero_terms_query")]
5964
ZeroTermsQuery? ZeroTermsQuery { get; set; }
6065
}
6166

@@ -66,6 +71,14 @@ public class MultiMatchQuery : QueryBase, IMultiMatchQuery
6671
public string Query { get; set; }
6772
public string Analyzer { get; set; }
6873
public RewriteMultiTerm? FuzzyRewrite { get; set; }
74+
75+
/// <summary>
76+
/// Allows fuzzy matching based on the type of field being queried.
77+
/// Cannot be used with the
78+
/// <see cref="TextQueryType.CrossFields"/>,
79+
/// <see cref="TextQueryType.Phrase"/> or
80+
/// <see cref="TextQueryType.PhrasePrefix"/> types.
81+
/// </summary>
6982
public Fuzziness Fuzziness { get; set; }
7083
public double? CutoffFrequency { get; set; }
7184
public int? PrefixLength { get; set; }
@@ -116,6 +129,13 @@ public MultiMatchQueryDescriptor<T> Fields(Func<FieldsDescriptor<T>, IPromise<Fi
116129

117130
public MultiMatchQueryDescriptor<T> Analyzer(string analyzer) => Assign(a => a.Analyzer = analyzer);
118131

132+
/// <summary>
133+
/// Allows fuzzy matching based on the type of field being queried.
134+
/// Cannot be used with the
135+
/// <see cref="TextQueryType.CrossFields"/>,
136+
/// <see cref="TextQueryType.Phrase"/> or
137+
/// <see cref="TextQueryType.PhrasePrefix"/> types.
138+
/// </summary>
119139
public MultiMatchQueryDescriptor<T> Fuzziness(Fuzziness fuzziness) => Assign(a => a.Fuzziness = fuzziness);
120140

121141
public MultiMatchQueryDescriptor<T> CutoffFrequency(double cutoffFrequency)

0 commit comments

Comments
 (0)