@@ -9,50 +9,89 @@ namespace Nest
9
9
[ JsonConverter ( typeof ( ReadAsTypeJsonConverter < CompletionSuggester > ) ) ]
10
10
public interface ICompletionSuggester : ISuggester
11
11
{
12
+ /// <summary>
13
+ /// Prefix used to search for suggestions
14
+ /// </summary>
12
15
[ JsonIgnore ]
13
16
string Prefix { get ; set ; }
14
17
18
+ /// <summary>
19
+ /// Prefix as a regular expression used to search for suggestions
20
+ /// </summary>
15
21
[ JsonIgnore ]
16
22
string Regex { get ; set ; }
17
23
24
+ /// <summary>
25
+ /// Support fuzziness for the suggestions
26
+ /// </summary>
18
27
[ JsonProperty ( "fuzzy" ) ]
19
28
IFuzzySuggester Fuzzy { get ; set ; }
20
29
30
+ /// <summary>
31
+ /// Context mappings used to filter and/or boost suggestions
32
+ /// </summary>
21
33
[ JsonProperty ( "contexts" ) ]
22
34
IDictionary < string , IList < ISuggestContextQuery > > Contexts { get ; set ; }
35
+
36
+ /// <summary>
37
+ /// Whether duplicate suggestions should be filtered out. Defaults to <c>false</c>
38
+ /// </summary>
39
+ [ JsonProperty ( "skip_duplicates" ) ]
40
+ bool ? SkipDuplicates { get ; set ; }
23
41
}
24
42
25
43
public class CompletionSuggester : SuggesterBase , ICompletionSuggester
26
44
{
45
+ /// <inheritdoc />
27
46
public IFuzzySuggester Fuzzy { get ; set ; }
28
47
48
+ /// <inheritdoc />
29
49
public IDictionary < string , IList < ISuggestContextQuery > > Contexts { get ; set ; }
30
50
51
+ /// <inheritdoc />
31
52
public string Prefix { get ; set ; }
32
53
54
+ /// <inheritdoc />
33
55
public string Regex { get ; set ; }
56
+
57
+ /// <inheritdoc />
58
+ public bool ? SkipDuplicates { get ; set ; }
34
59
}
35
60
36
61
public class CompletionSuggesterDescriptor < T > : SuggestDescriptorBase < CompletionSuggesterDescriptor < T > , ICompletionSuggester , T > , ICompletionSuggester
37
62
where T : class
38
63
{
39
64
IFuzzySuggester ICompletionSuggester . Fuzzy { get ; set ; }
40
-
41
65
IDictionary < string , IList < ISuggestContextQuery > > ICompletionSuggester . Contexts { get ; set ; }
42
-
43
66
string ICompletionSuggester . Prefix { get ; set ; }
44
-
45
67
string ICompletionSuggester . Regex { get ; set ; }
68
+ bool ? ICompletionSuggester . SkipDuplicates { get ; set ; }
46
69
70
+ /// <summary>
71
+ /// Prefix used to search for suggestions
72
+ /// </summary>
47
73
public CompletionSuggesterDescriptor < T > Prefix ( string prefix ) => Assign ( a => a . Prefix = prefix ) ;
48
74
75
+ /// <summary>
76
+ /// Prefix as a regular expression used to search for suggestions
77
+ /// </summary>
49
78
public CompletionSuggesterDescriptor < T > Regex ( string regex ) => Assign ( a => a . Regex = regex ) ;
50
79
80
+ /// <summary>
81
+ /// Support fuzziness for the suggestions
82
+ /// </summary>
51
83
public CompletionSuggesterDescriptor < T > Fuzzy ( Func < FuzzySuggestDescriptor < T > , IFuzzySuggester > selector = null ) =>
52
84
Assign ( a => a . Fuzzy = selector . InvokeOrDefault ( new FuzzySuggestDescriptor < T > ( ) ) ) ;
53
85
86
+ /// <summary>
87
+ /// Context mappings used to filter and/or boost suggestions
88
+ /// </summary>
54
89
public CompletionSuggesterDescriptor < T > Contexts ( Func < SuggestContextQueriesDescriptor < T > , IPromise < IDictionary < string , IList < ISuggestContextQuery > > > > contexts ) =>
55
90
Assign ( a => a . Contexts = contexts ? . Invoke ( new SuggestContextQueriesDescriptor < T > ( ) ) . Value ) ;
56
91
92
+ /// <summary>
93
+ /// Whether duplicate suggestions should be filtered out. Defaults to <c>false</c>
94
+ /// </summary>
95
+ public CompletionSuggesterDescriptor < T > SkipDuplicates ( bool ? skipDuplicates = true ) => Assign ( a => a . SkipDuplicates = skipDuplicates ) ;
57
96
}
58
97
}
0 commit comments