@@ -144,30 +144,40 @@ async function insertIntoES (modelName, dataset) {
144
144
const chunked = _ . chunk ( dataset , config . get ( 'ES.MAX_BULK_SIZE' ) )
145
145
for ( const ds of chunked ) {
146
146
const body = _ . flatMap ( ds , doc => [ { index : { _id : doc . id } } , doc ] )
147
- await client . bulk ( {
148
- index : topResources [ esResourceName ] . index ,
149
- type : topResources [ esResourceName ] . type ,
150
- body,
151
- pipeline : topResources [ esResourceName ] . ingest ? topResources [ esResourceName ] . ingest . pipeline . id : undefined ,
152
- refresh : 'wait_for'
153
- } )
147
+ try {
148
+ await client . bulk ( {
149
+ index : topResources [ esResourceName ] . index ,
150
+ type : topResources [ esResourceName ] . type ,
151
+ body,
152
+ pipeline : topResources [ esResourceName ] . ingest ? topResources [ esResourceName ] . ingest . pipeline . id : undefined ,
153
+ refresh : 'wait_for'
154
+ } )
155
+ } catch ( e ) {
156
+ logger . error ( 'ES, create mapping error.' )
157
+ logger . error ( JSON . stringify ( e ) )
158
+ }
154
159
}
155
160
} else if ( _ . includes ( _ . keys ( userResources ) , esResourceName ) ) {
156
161
const userResource = userResources [ esResourceName ]
157
162
158
163
if ( userResource . nested === true && userResource . mappingCreated !== true ) {
159
- await client . indices . putMapping ( {
160
- index : topResources . user . index ,
161
- type : topResources . user . type ,
162
- include_type_name : true ,
163
- body : {
164
- properties : {
165
- [ userResource . propertyName ] : {
166
- type : 'nested'
164
+ try {
165
+ await client . indices . putMapping ( {
166
+ index : topResources . user . index ,
167
+ type : topResources . user . type ,
168
+ include_type_name : true ,
169
+ body : {
170
+ properties : {
171
+ [ userResource . propertyName ] : {
172
+ type : 'nested'
173
+ }
167
174
}
168
175
}
169
- }
170
- } )
176
+ } )
177
+ } catch ( e ) {
178
+ logger . error ( 'ES, nexted mapping error.' )
179
+ logger . error ( JSON . stringify ( e ) )
180
+ }
171
181
userResource . mappingCreated = true
172
182
}
173
183
0 commit comments