@@ -35,34 +35,52 @@ func TestSearch_ListIndexes(t *testing.T) {
35
35
mux .HandleFunc (fmt .Sprintf ("/api/atlas/v1.0/groups/%s/clusters/%s/fts/indexes/%s/%s" , groupID , clusterName , databaseName , collectionName ), func (w http.ResponseWriter , r * http.Request ) {
36
36
testMethod (t , r , http .MethodGet )
37
37
fmt .Fprint (w , `[
38
- {
39
- "collectionName": "movies",
40
- "database": "sample_mflix",
41
- "indexID": "5d114a3587d9d65de99e7371",
42
- "mappings": {
43
- "dynamic": true
44
- },
45
- "name": "default"
46
- },
47
- {
48
- "collectionName": "movies",
49
- "database": "sample_mflix",
50
- "indexID": "5d1268a980eef518dac0cf41",
51
- "mappings": {
52
- "dynamic": false,
53
- "fields": {
54
- "genres" : {
55
- "analyzer": "lucene.standard",
56
- "type": "string"
38
+ {
39
+ "collectionName": "movies",
40
+ "database": "sample_mflix",
41
+ "indexID": "5d114a3587d9d65de99e7371",
42
+ "mappings": {
43
+ "dynamic": true
57
44
},
58
- "plot": {
59
- "analyzer": "lucene.standard",
60
- "type": "string"
61
- }
62
- }
45
+ "name": "default",
46
+ "synonyms": [
47
+ {
48
+ "analyzer": "lucene.english",
49
+ "name": "mySynonyms",
50
+ "source": {
51
+ "collection": "synonyms"
52
+ }
53
+ }
54
+ ]
63
55
},
64
- "name": "SearchIndex1"
65
- }
56
+ {
57
+ "collectionName": "movies",
58
+ "database": "sample_mflix",
59
+ "indexID": "5d1268a980eef518dac0cf41",
60
+ "mappings": {
61
+ "dynamic": false,
62
+ "fields": {
63
+ "genres" : {
64
+ "analyzer": "lucene.standard",
65
+ "type": "string"
66
+ },
67
+ "plot": {
68
+ "analyzer": "lucene.standard",
69
+ "type": "string"
70
+ }
71
+ }
72
+ },
73
+ "name": "SearchIndex1",
74
+ "synonyms": [
75
+ {
76
+ "analyzer": "lucene.english",
77
+ "name": "mySynonyms",
78
+ "source": {
79
+ "collection": "synonyms"
80
+ }
81
+ }
82
+ ]
83
+ }
66
84
]` )
67
85
})
68
86
@@ -80,6 +98,15 @@ func TestSearch_ListIndexes(t *testing.T) {
80
98
Dynamic : true ,
81
99
},
82
100
Name : "default" ,
101
+ Synonyms : []map [string ]interface {}{
102
+ {
103
+ "analyzer" : "lucene.english" ,
104
+ "name" : "mySynonyms" ,
105
+ "source" : map [string ]interface {}{
106
+ "collection" : "synonyms" ,
107
+ },
108
+ },
109
+ },
83
110
},
84
111
{
85
112
CollectionName : "movies" ,
@@ -99,6 +126,15 @@ func TestSearch_ListIndexes(t *testing.T) {
99
126
},
100
127
},
101
128
Name : "SearchIndex1" ,
129
+ Synonyms : []map [string ]interface {}{
130
+ {
131
+ "analyzer" : "lucene.english" ,
132
+ "name" : "mySynonyms" ,
133
+ "source" : map [string ]interface {}{
134
+ "collection" : "synonyms" ,
135
+ },
136
+ },
137
+ },
102
138
},
103
139
}
104
140
@@ -118,23 +154,32 @@ func TestSearch_GetIndex(t *testing.T) {
118
154
mux .HandleFunc (fmt .Sprintf ("/api/atlas/v1.0/groups/%s/clusters/%s/fts/indexes/%s" , projectID , clusterName , indexID ), func (w http.ResponseWriter , r * http.Request ) {
119
155
testMethod (t , r , http .MethodGet )
120
156
fmt .Fprint (w , `{
121
- "collectionName": "movies",
122
- "database": "sample_mflix",
123
- "indexID": "5d1268a980eef518dac0cf41",
124
- "mappings": {
125
- "dynamic": false,
126
- "fields": {
127
- "genres": {
128
- "analyzer": "lucene.standard",
129
- "type": "string"
130
- },
131
- "plot": {
132
- "analyzer": "lucene.standard",
133
- "type": "string"
134
- }
135
- }
136
- },
137
- "name": "SearchIndex1"
157
+ "collectionName": "movies",
158
+ "database": "sample_mflix",
159
+ "indexID": "5d1268a980eef518dac0cf41",
160
+ "mappings": {
161
+ "dynamic": false,
162
+ "fields": {
163
+ "genres": {
164
+ "analyzer": "lucene.standard",
165
+ "type": "string"
166
+ },
167
+ "plot": {
168
+ "analyzer": "lucene.standard",
169
+ "type": "string"
170
+ }
171
+ }
172
+ },
173
+ "name": "SearchIndex1",
174
+ "synonyms": [
175
+ {
176
+ "analyzer": "lucene.english",
177
+ "name": "mySynonyms",
178
+ "source": {
179
+ "collection": "synonyms"
180
+ }
181
+ }
182
+ ]
138
183
}` )
139
184
})
140
185
@@ -161,6 +206,15 @@ func TestSearch_GetIndex(t *testing.T) {
161
206
},
162
207
},
163
208
Name : "SearchIndex1" ,
209
+ Synonyms : []map [string ]interface {}{
210
+ {
211
+ "analyzer" : "lucene.english" ,
212
+ "name" : "mySynonyms" ,
213
+ "source" : map [string ]interface {}{
214
+ "collection" : "synonyms" ,
215
+ },
216
+ },
217
+ },
164
218
}
165
219
166
220
if diff := deep .Equal (index , expected ); diff != nil {
@@ -203,13 +257,22 @@ func TestSearchServiceOp_CreateIndex(t *testing.T) {
203
257
}
204
258
205
259
jsonBlob := `{
206
- "collectionName" : "orders",
207
- "database" : "fiscalYear2018",
208
- "indexID" : "5d12990380eef5303341accd",
209
- "mappings" : {
210
- "dynamic" : true
211
- },
212
- "name" : "default"
260
+ "collectionName" : "orders",
261
+ "database" : "fiscalYear2018",
262
+ "indexID" : "5d12990380eef5303341accd",
263
+ "mappings" : {
264
+ "dynamic" : true
265
+ },
266
+ "name" : "default",
267
+ "synonyms": [
268
+ {
269
+ "analyzer": "lucene.english",
270
+ "name": "mySynonyms",
271
+ "source": {
272
+ "collection": "synonyms"
273
+ }
274
+ }
275
+ ]
213
276
}`
214
277
fmt .Fprint (w , jsonBlob )
215
278
})
@@ -225,6 +288,15 @@ func TestSearchServiceOp_CreateIndex(t *testing.T) {
225
288
IndexID : "5d12990380eef5303341accd" ,
226
289
Mappings : & IndexMapping {Dynamic : true },
227
290
Name : "default" ,
291
+ Synonyms : []map [string ]interface {}{
292
+ {
293
+ "analyzer" : "lucene.english" ,
294
+ "name" : "mySynonyms" ,
295
+ "source" : map [string ]interface {}{
296
+ "collection" : "synonyms" ,
297
+ },
298
+ },
299
+ },
228
300
}
229
301
230
302
if diff := deep .Equal (index , expected ); diff != nil {
@@ -272,15 +344,15 @@ func TestSearchServiceOp_UpdateIndex(t *testing.T) {
272
344
}
273
345
274
346
jsonBlob := `{
275
- "analyzer" : "lucene.swedish",
276
- "searchAnalyzer" : "lucene.whitespace",
277
- "collectionName" : "orders",
278
- "database" : "fiscalYear2018",
279
- "indexID" : "5d129aef87d9d64f310bd79f",
280
- "mappings" : {
281
- "dynamic" : true
282
- },
283
- "name" : "2018ordersIndex"
347
+ "analyzer" : "lucene.swedish",
348
+ "searchAnalyzer" : "lucene.whitespace",
349
+ "collectionName" : "orders",
350
+ "database" : "fiscalYear2018",
351
+ "indexID" : "5d129aef87d9d64f310bd79f",
352
+ "mappings" : {
353
+ "dynamic" : true
354
+ },
355
+ "name" : "2018ordersIndex"
284
356
}`
285
357
fmt .Fprint (w , jsonBlob )
286
358
})
@@ -330,16 +402,16 @@ func TestSearch_ListAnalyzers(t *testing.T) {
330
402
mux .HandleFunc (fmt .Sprintf ("/api/atlas/v1.0/groups/%s/clusters/%s/fts/analyzers" , groupID , clusterName ), func (w http.ResponseWriter , r * http.Request ) {
331
403
testMethod (t , r , http .MethodGet )
332
404
fmt .Fprint (w , `[
333
- {
334
- "baseAnalyzer" : "lucene.standard",
335
- "maxTokenLength" : 32,
336
- "name" : "my_new_analyzer"
337
- },
338
- {
339
- "baseAnalyzer" : "lucene.english",
340
- "name" : "my_new_analyzer2",
341
- "stopwords" : [ "first", "second", "third", "etc" ]
342
- }
405
+ {
406
+ "baseAnalyzer" : "lucene.standard",
407
+ "maxTokenLength" : 32,
408
+ "name" : "my_new_analyzer"
409
+ },
410
+ {
411
+ "baseAnalyzer" : "lucene.english",
412
+ "name" : "my_new_analyzer2",
413
+ "stopwords" : [ "first", "second", "third", "etc" ]
414
+ }
343
415
]` )
344
416
})
345
417
@@ -374,17 +446,17 @@ func TestSearch_UpdateAllAnalyzers(t *testing.T) {
374
446
mux .HandleFunc (fmt .Sprintf ("/api/atlas/v1.0/groups/%s/clusters/%s/fts/analyzers" , groupID , clusterName ), func (w http.ResponseWriter , r * http.Request ) {
375
447
testMethod (t , r , http .MethodPut )
376
448
fmt .Fprint (w , `[
377
- {
378
- "baseAnalyzer" : "lucene.standard",
379
- "maxTokenLength" : 32,
380
- "name" : "my_new_analyzer",
381
- "ignoreCase": true
382
- },
383
- {
384
- "baseAnalyzer" : "lucene.english",
385
- "name" : "my_new_analyzer2",
386
- "stopwords" : [ "first", "second", "third", "etc" ]
387
- }
449
+ {
450
+ "baseAnalyzer" : "lucene.standard",
451
+ "maxTokenLength" : 32,
452
+ "name" : "my_new_analyzer",
453
+ "ignoreCase": true
454
+ },
455
+ {
456
+ "baseAnalyzer" : "lucene.english",
457
+ "name" : "my_new_analyzer2",
458
+ "stopwords" : [ "first", "second", "third", "etc" ]
459
+ }
388
460
]` )
389
461
})
390
462
0 commit comments