88
99namespace Nest . Tests . Unit . Search . Suggest
1010{
11- [ TestFixture ]
12- public class CompletionSuggestTests : BaseJsonTests
13- {
14- [ Test ]
15- public void CompletionSuggestDescriptorTest ( )
16- {
17- var completionSuggestDescriptor = new CompletionSuggestDescriptor < ElasticsearchProject > ( )
18- . OnField ( "suggest" )
19- . Text ( "n" ) ;
20-
21- var json = TestElasticClient . Serialize ( completionSuggestDescriptor ) ;
22-
23- var expected = @"{ "" field"" : ""suggest"" }" ;
24-
25- Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
26- }
27-
28- [ Test ]
29- public void CompletionSuggestDescriptorDefaultFuzzyTest ( )
30- {
31- var completionSuggestDescriptor = new CompletionSuggestDescriptor < ElasticsearchProject > ( )
32- . OnField ( "suggest" )
33- . Text ( "n" )
11+ [ TestFixture ]
12+ public class CompletionSuggestTests : BaseJsonTests
13+ {
14+ [ Test ]
15+ public void CompletionSuggestDescriptorTest ( )
16+ {
17+ var completionSuggestDescriptor = new CompletionSuggestDescriptor < ElasticsearchProject > ( )
18+ . OnField ( "suggest" )
19+ . Text ( "n" ) ;
20+
21+ var json = TestElasticClient . Serialize ( completionSuggestDescriptor ) ;
22+
23+ var expected = @"{ field: ""suggest"" }" ;
24+
25+ Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
26+ }
27+
28+ [ Test ]
29+ public void CompletionSuggestDescriptorDefaultFuzzyTest ( )
30+ {
31+ var completionSuggestDescriptor = new CompletionSuggestDescriptor < ElasticsearchProject > ( )
32+ . OnField ( "suggest" )
33+ . Text ( "n" )
3434 . Fuzzy ( ) ;
3535
36- var json = TestElasticClient . Serialize ( completionSuggestDescriptor ) ;
36+ var json = TestElasticClient . Serialize ( completionSuggestDescriptor ) ;
3737
38- var expected = @"{
39- "" fuzzy"" : {
40- "" edit_distance"" : 1,
41- "" transpositions"" : true,
42- "" min_length"" : 3,
43- "" prefix_length"" : 1
38+ var expected = @"{
39+ fuzzy: {
40+ edit_distance: 1,
41+ transpositions: true,
42+ min_length: 3,
43+ prefix_length: 1
4444 },
45- "" field"" : ""suggest""
45+ field: ""suggest""
4646 }" ;
4747
48- Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
49- }
48+ Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
49+ }
5050
5151 [ Test ]
5252 public void CompletionSuggestDescriptorDefaultFuzzinessTest ( )
@@ -59,40 +59,41 @@ public void CompletionSuggestDescriptorDefaultFuzzinessTest()
5959 var json = TestElasticClient . Serialize ( completionSuggestDescriptor ) ;
6060
6161 var expected = @"{
62- ""fuzzy"": {
62+ fuzzy: {
63+ fuzziness: {}
6364 },
64- "" field"" : ""suggest""
65+ field: ""suggest""
6566 }" ;
6667
6768 Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
6869 }
6970
70- [ Test ]
71- public void CompletionSuggestDescriptorFuzzyTest ( )
72- {
73- var completionSuggestDescriptor = new CompletionSuggestDescriptor < ElasticsearchProject > ( )
74- . OnField ( "suggest" )
75- . Text ( "n" )
76- . Fuzzy ( f => f
77- . EditDistance ( 2 )
78- . Transpositions ( false )
79- . MinLength ( 5 )
80- . PrefixLength ( 4 ) ) ;
81-
82- var json = TestElasticClient . Serialize ( completionSuggestDescriptor ) ;
83-
84- var expected = @"{
85- "" fuzzy"": {
86- "" edit_distance"" : 2,
87- "" transpositions"" : false,
88- "" min_length"" : 5,
89- "" prefix_length"" : 4
71+ [ Test ]
72+ public void CompletionSuggestDescriptorFuzzyTest ( )
73+ {
74+ var completionSuggestDescriptor = new CompletionSuggestDescriptor < ElasticsearchProject > ( )
75+ . OnField ( "suggest" )
76+ . Text ( "n" )
77+ . Fuzzy ( f => f
78+ . EditDistance ( 2 )
79+ . Transpositions ( false )
80+ . MinLength ( 5 )
81+ . PrefixLength ( 4 ) ) ;
82+
83+ var json = TestElasticClient . Serialize ( completionSuggestDescriptor ) ;
84+
85+ var expected = @"{
86+ fuzzy"": {
87+ edit_distance: 2,
88+ transpositions: false,
89+ min_length: 5,
90+ prefix_length: 4
9091 },
91- "" field"" : ""suggest""
92+ field: ""suggest""
9293 }" ;
9394
94- Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
95- }
95+ Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
96+ }
9697
9798 [ Test ]
9899 public void CompletionSuggestDescriptorFuzzinessTest ( )
@@ -105,10 +106,10 @@ public void CompletionSuggestDescriptorFuzzinessTest()
105106 var json = TestElasticClient . Serialize ( completionSuggestDescriptor ) ;
106107
107108 var expected = @"{
108- "" fuzzy"" : {
109- "" fuzziness"" : 1
109+ fuzzy: {
110+ fuzziness: 1
110111 },
111- "" field"" : ""suggest""
112+ field: ""suggest""
112113 }" ;
113114
114115 Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
@@ -125,10 +126,10 @@ public void CompletionSuggestDescriptorFuzzinessDoubleTest()
125126 var json = TestElasticClient . Serialize ( completionSuggestDescriptor ) ;
126127
127128 var expected = @"{
128- "" fuzzy"" : {
129- "" fuzziness"" : 0.4
129+ fuzzy: {
130+ fuzziness: 0.4
130131 },
131- "" field"" : ""suggest""
132+ field: ""suggest""
132133 }" ;
133134
134135 Assert . IsTrue ( json . JsonEquals ( expected ) , json ) ;
@@ -140,7 +141,7 @@ public void CompletionSuggestOnSearchTest()
140141 var search = this . _client . Search < ElasticsearchProject > ( s => s
141142 . SuggestCompletion ( "mycompletionsuggest" , ts => ts
142143 . Text ( "n" )
143- . OnField ( p=> p . Name )
144+ . OnField ( p => p . Name )
144145 . Fuzzy ( )
145146 )
146147 ) ;
@@ -182,6 +183,7 @@ public void CompletionSuggestWithFuzzinessOnSearchTest()
182183 text: ""n"",
183184 completion: {
184185 fuzzy: {
186+ fuzziness: {}
185187 },
186188 field: ""name""
187189 }
@@ -191,5 +193,5 @@ public void CompletionSuggestWithFuzzinessOnSearchTest()
191193 var json = search . ConnectionStatus . Request . Utf8String ( ) ;
192194 Assert . True ( json . JsonEquals ( expected ) , json ) ;
193195 }
194- }
196+ }
195197}
0 commit comments