@@ -116,22 +116,9 @@ func (opts *IndexOpts) DeprecatedNewSearchIndex() (*atlasv2.ClusterSearchIndex,
116
116
return i , nil
117
117
}
118
118
119
- func IndexResponseToDeprecated (r * atlasv2.SearchIndexResponse ) * atlasv2.ClusterSearchIndex {
120
- return & atlasv2.ClusterSearchIndex {
121
- CollectionName : * r .CollectionName ,
122
- Database : * r .Database ,
123
- Mappings : (* atlasv2 .ApiAtlasFTSMappings )(r .LatestDefinition .Mappings ),
124
- Name : * r .Name ,
125
- SearchAnalyzer : r .LatestDefinition .SearchAnalyzer ,
126
- Status : r .Status ,
127
- Type : r .Type ,
128
- IndexID : r .IndexID ,
129
- }
130
- }
131
-
132
- func (opts * IndexOpts ) NewSearchIndex () (* atlasv2.SearchIndexCreateRequest , error ) {
119
+ func (opts * IndexOpts ) NewSearchIndex () (* atlasv2.ClusterSearchIndex , error ) {
133
120
if len (opts .Filename ) > 0 {
134
- index := & atlasv2.SearchIndexCreateRequest {}
121
+ index := & atlasv2.ClusterSearchIndex {}
135
122
if err := file .Load (opts .Fs , opts .Filename , index ); err != nil {
136
123
return nil , fmt .Errorf (failedToLoadIndexMessage , err .Error ())
137
124
}
@@ -152,51 +139,17 @@ func (opts *IndexOpts) NewSearchIndex() (*atlasv2.SearchIndexCreateRequest, erro
152
139
opts .SearchAnalyzer = DefaultAnalyzer
153
140
}
154
141
155
- i := & atlasv2.SearchIndexCreateRequest {
142
+ i := & atlasv2.ClusterSearchIndex {
156
143
CollectionName : opts .Collection ,
157
144
Database : opts .DBName ,
158
145
Name : opts .Name ,
159
146
// only search indexes can be created using flags
160
- Type : pointer .Get (SearchIndexType ),
161
- Definition : & atlasv2.BaseSearchIndexCreateRequestDefinition {
162
- Analyzer : & opts .Analyzer ,
163
- SearchAnalyzer : & opts .SearchAnalyzer ,
164
- Mappings : & atlasv2.SearchMappings {
165
- Dynamic : & opts .Dynamic ,
166
- Fields : f ,
167
- },
168
- },
169
- }
170
- return i , nil
171
- }
172
-
173
- func (opts * IndexOpts ) NewSearchIndexUpdate () (* atlasv2.SearchIndexUpdateRequest , error ) {
174
- if len (opts .Filename ) > 0 {
175
- index := & atlasv2.SearchIndexUpdateRequest {}
176
- if err := file .Load (opts .Fs , opts .Filename , index ); err != nil {
177
- return nil , fmt .Errorf (failedToLoadIndexMessage , err .Error ())
178
- }
179
-
180
- return index , nil
181
- }
182
-
183
- f , err := opts .indexFields ()
184
- if err != nil {
185
- return nil , err
186
- }
187
-
188
- if opts .SearchAnalyzer == "" {
189
- opts .SearchAnalyzer = DefaultAnalyzer
190
- }
191
-
192
- i := & atlasv2.SearchIndexUpdateRequest {
193
- Definition : atlasv2.SearchIndexUpdateRequestDefinition {
194
- Analyzer : & opts .Analyzer ,
195
- SearchAnalyzer : & opts .SearchAnalyzer ,
196
- Mappings : & atlasv2.SearchMappings {
197
- Dynamic : & opts .Dynamic ,
198
- Fields : f ,
199
- },
147
+ Type : pointer .Get (SearchIndexType ),
148
+ Analyzer : & opts .Analyzer ,
149
+ SearchAnalyzer : & opts .SearchAnalyzer ,
150
+ Mappings : & atlasv2.ApiAtlasFTSMappings {
151
+ Dynamic : & opts .Dynamic ,
152
+ Fields : f ,
200
153
},
201
154
}
202
155
return i , nil
0 commit comments