@@ -70,8 +70,10 @@ func TestSearch(t *testing.T) {
70
70
"collectionName": "{{ .collectionName }}",
71
71
"database": "test",
72
72
"name": "{{ .indexName }}",
73
- "mappings": {
74
- "dynamic": true
73
+ "definition": {
74
+ "mappings": {
75
+ "dynamic": true
76
+ }
75
77
}
76
78
}` ))
77
79
require .NoError (t , tpl .Execute (file , map [string ]string {
@@ -93,7 +95,7 @@ func TestSearch(t *testing.T) {
93
95
cmd .Env = os .Environ ()
94
96
resp , err := e2e .RunAndGetStdOut (cmd )
95
97
require .NoError (t , err , string (resp ))
96
- var index atlasv2.ClusterSearchIndex
98
+ var index atlasv2.SearchIndexResponse
97
99
require .NoError (t , json .Unmarshal (resp , & index ))
98
100
assert .Equal (t , index .GetName (), indexName )
99
101
indexID = index .GetIndexID ()
@@ -112,7 +114,7 @@ func TestSearch(t *testing.T) {
112
114
cmd .Env = os .Environ ()
113
115
resp , err := e2e .RunAndGetStdOut (cmd )
114
116
require .NoError (t , err , string (resp ))
115
- var index atlasv2.ClusterSearchIndex
117
+ var index atlasv2.SearchIndexResponse
116
118
require .NoError (t , json .Unmarshal (resp , & index ))
117
119
assert .Equal (t , indexID , index .GetIndexID ())
118
120
})
@@ -126,15 +128,13 @@ func TestSearch(t *testing.T) {
126
128
t .Cleanup (func () {
127
129
require .NoError (t , os .Remove (fileName ))
128
130
})
129
-
130
131
tpl := template .Must (template .New ("" ).Parse (`
131
132
{
132
- "collectionName": "{{ .collectionName }}",
133
- "database": "test",
134
- "name": "{{ .indexName }}",
135
- "analyzer": "{{ .analyzer }}",
136
- "mappings": {
137
- "dynamic": true
133
+ "definition": {
134
+ "analyzer": "{{ .analyzer }}",
135
+ "mappings": {
136
+ "dynamic": true
137
+ }
138
138
}
139
139
}` ))
140
140
require .NoError (t , tpl .Execute (file , map [string ]string {
@@ -158,11 +158,12 @@ func TestSearch(t *testing.T) {
158
158
cmd .Env = os .Environ ()
159
159
resp , err := e2e .RunAndGetStdOut (cmd )
160
160
require .NoError (t , err , string (resp ))
161
- var index atlasv2.ClusterSearchIndex
161
+ var index atlasv2.SearchIndexResponse
162
162
require .NoError (t , json .Unmarshal (resp , & index ))
163
163
a := assert .New (t )
164
164
a .Equal (indexID , index .GetIndexID ())
165
- a .Equal (analyzer , index .GetAnalyzer ())
165
+ def := index .GetLatestDefinition ()
166
+ a .Equal (analyzer , def .GetAnalyzer ())
166
167
})
167
168
168
169
t .Run ("Delete" , func (t * testing.T ) {
@@ -196,31 +197,33 @@ func TestSearch(t *testing.T) {
196
197
"collectionName": "planets",
197
198
"database": "sample_guides",
198
199
"name": "{{ .indexName }}",
199
- "analyzer": "lucene.standard",
200
- "searchAnalyzer": "lucene.standard",
201
- "mappings": {
202
- "dynamic": false,
203
- "fields": {
204
- "name": {
205
- "type": "string",
206
- "analyzer": "lucene.whitespace",
207
- "multi": {
208
- "mySecondaryAnalyzer": {
209
- "type": "string",
210
- "analyzer": "lucene.french"
211
- }
212
- }
213
- },
214
- "mainAtmosphere": {
215
- "type": "string",
216
- "analyzer": "lucene.standard"
217
- },
218
- "surfaceTemperatureC": {
219
- "type": "document",
220
- "dynamic": true,
221
- "analyzer": "lucene.standard"
222
- }
223
- }
200
+ "definition": {
201
+ "analyzer": "lucene.standard",
202
+ "searchAnalyzer": "lucene.standard",
203
+ "mappings": {
204
+ "dynamic": false,
205
+ "fields": {
206
+ "name": {
207
+ "type": "string",
208
+ "analyzer": "lucene.whitespace",
209
+ "multi": {
210
+ "mySecondaryAnalyzer": {
211
+ "type": "string",
212
+ "analyzer": "lucene.french"
213
+ }
214
+ }
215
+ },
216
+ "mainAtmosphere": {
217
+ "type": "string",
218
+ "analyzer": "lucene.standard"
219
+ },
220
+ "surfaceTemperatureC": {
221
+ "type": "document",
222
+ "dynamic": true,
223
+ "analyzer": "lucene.standard"
224
+ }
225
+ }
226
+ }
224
227
}
225
228
}` ))
226
229
require .NoError (t , tpl .Execute (file , map [string ]string {
@@ -241,9 +244,9 @@ func TestSearch(t *testing.T) {
241
244
cmd .Env = os .Environ ()
242
245
resp , err := e2e .RunAndGetStdOut (cmd )
243
246
require .NoError (t , err , string (resp ))
244
- var index atlasv2.ClusterSearchIndex
247
+ var index atlasv2.SearchIndexResponse
245
248
require .NoError (t , json .Unmarshal (resp , & index ))
246
- assert .Equal (t , indexName , index .Name )
249
+ assert .Equal (t , indexName , index .GetName () )
247
250
})
248
251
249
252
t .Run ("Create staticMapping" , func (t * testing.T ) {
@@ -260,71 +263,73 @@ func TestSearch(t *testing.T) {
260
263
"collectionName": "posts",
261
264
"database": "sample_training",
262
265
"name": "{{ .indexName }}",
263
- "analyzer": "lucene.standard",
264
- "searchAnalyzer": "lucene.standard",
265
- "mappings": {
266
- "dynamic": false,
267
- "fields": {
268
- "comments": {
269
- "type": "document",
270
- "fields": {
271
- "body": {
272
- "type": "string",
273
- "analyzer": "lucene.simple",
274
- "ignoreAbove": 255
275
- },
276
- "author": {
277
- "type": "string",
278
- "analyzer": "keywordLowerCase"
279
- }
280
- }
281
- },
282
- "body": {
283
- "type": "string",
284
- "analyzer": "lucene.whitespace",
285
- "multi": {
286
- "mySecondaryAnalyzer": {
287
- "type": "string",
288
- "analyzer": "keywordLowerCase"
289
- }
290
- }
291
- },
292
- "tags": {
293
- "type": "string",
294
- "analyzer": "standardLowerCase"
295
- }
296
- }
297
- },
298
- "analyzers":[
299
- {
300
- "charFilters":[
301
-
302
- ],
303
- "name":"keywordLowerCase",
304
- "tokenFilters":[
305
- {
306
- "type":"lowercase"
307
- }
308
- ],
309
- "tokenizer":{
310
- "type":"keyword"
311
- }
312
- },
313
- {
314
- "charFilters":[
315
-
316
- ],
317
- "name":"standardLowerCase",
318
- "tokenFilters":[
319
- {
320
- "type":"lowercase"
321
- }
322
- ],
323
- "tokenizer":{
324
- "type":"standard"
325
- }
326
- }
327
- ]
266
+ "definition": {
267
+ "analyzer": "lucene.standard",
268
+ "searchAnalyzer": "lucene.standard",
269
+ "mappings": {
270
+ "dynamic": false,
271
+ "fields": {
272
+ "comments": {
273
+ "type": "document",
274
+ "fields": {
275
+ "body": {
276
+ "type": "string",
277
+ "analyzer": "lucene.simple",
278
+ "ignoreAbove": 255
279
+ },
280
+ "author": {
281
+ "type": "string",
282
+ "analyzer": "keywordLowerCase"
283
+ }
284
+ }
285
+ },
286
+ "body": {
287
+ "type": "string",
288
+ "analyzer": "lucene.whitespace",
289
+ "multi": {
290
+ "mySecondaryAnalyzer": {
291
+ "type": "string",
292
+ "analyzer": "keywordLowerCase"
293
+ }
294
+ }
295
+ },
296
+ "tags": {
297
+ "type": "string",
298
+ "analyzer": "standardLowerCase"
299
+ }
300
+ }
301
+ },
302
+ "analyzers":[
303
+ {
304
+ "charFilters":[
305
+
306
+ ],
307
+ "name":"keywordLowerCase",
308
+ "tokenFilters":[
309
+ {
310
+ "type":"lowercase"
311
+ }
312
+ ],
313
+ "tokenizer":{
314
+ "type":"keyword"
315
+ }
316
+ },
317
+ {
318
+ "charFilters":[
319
+
320
+ ],
321
+ "name":"standardLowerCase",
322
+ "tokenFilters":[
323
+ {
324
+ "type":"lowercase"
325
+ }
326
+ ],
327
+ "tokenizer":{
328
+ "type":"standard"
329
+ }
330
+ }
331
+ ]
332
+ }
328
333
}` ))
329
334
require .NoError (t , tpl .Execute (file , map [string ]string {
330
335
"indexName" : indexName ,
@@ -344,9 +349,9 @@ func TestSearch(t *testing.T) {
344
349
cmd .Env = os .Environ ()
345
350
resp , err := e2e .RunAndGetStdOut (cmd )
346
351
require .NoError (t , err , string (resp ))
347
- var index atlasv2.ClusterSearchIndex
352
+ var index atlasv2.SearchIndexResponse
348
353
require .NoError (t , json .Unmarshal (resp , & index ))
349
- assert .Equal (t , indexName , index .Name )
354
+ assert .Equal (t , indexName , index .GetName () )
350
355
})
351
356
352
357
t .Run ("Create array mapping" , func (t * testing.T ) {
@@ -366,20 +371,22 @@ func TestSearch(t *testing.T) {
366
371
"collectionName": "posts",
367
372
"database": "sample_training",
368
373
"name": "{{ .indexName }}",
369
- "analyzer": "lucene.standard",
370
- "searchAnalyzer": "lucene.standard",
371
- "mappings": {
372
- "dynamic": false,
373
- "fields": {
374
- "comments": [
375
- {
376
- "dynamic": true,
377
- "type": "document"
378
- },
379
- {
380
- "type": "string"
381
- }]
382
- }
374
+ "definition": {
375
+ "analyzer": "lucene.standard",
376
+ "searchAnalyzer": "lucene.standard",
377
+ "mappings": {
378
+ "dynamic": false,
379
+ "fields": {
380
+ "comments": [
381
+ {
382
+ "dynamic": true,
383
+ "type": "document"
384
+ },
385
+ {
386
+ "type": "string"
387
+ }]
388
+ }
389
+ }
383
390
}
384
391
}` ))
385
392
require .NoError (t , tpl .Execute (file , map [string ]string {
@@ -400,9 +407,9 @@ func TestSearch(t *testing.T) {
400
407
cmd .Env = os .Environ ()
401
408
resp , err := e2e .RunAndGetStdOut (cmd )
402
409
require .NoError (t , err , string (resp ))
403
- var index atlasv2.ClusterSearchIndex
410
+ var index atlasv2.SearchIndexResponse
404
411
require .NoError (t , json .Unmarshal (resp , & index ))
405
- assert .Equal (t , indexName , index .Name )
412
+ assert .Equal (t , indexName , index .GetName () )
406
413
})
407
414
408
415
t .Run ("list" , func (t * testing.T ) {
@@ -421,7 +428,7 @@ func TestSearch(t *testing.T) {
421
428
resp , err := e2e .RunAndGetStdOut (cmd )
422
429
require .NoError (t , err , string (resp ))
423
430
424
- var indexes []atlasv2.ClusterSearchIndex
431
+ var indexes []atlasv2.SearchIndexResponse
425
432
require .NoError (t , json .Unmarshal (resp , & indexes ))
426
433
assert .NotEmpty (t , indexes )
427
434
})
0 commit comments