Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 878b94d

Browse files
author
Sachin Maheshwari
committed
for fixing nested looping error
1 parent 444c257 commit 878b94d

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

scripts/db/dumpDbToEs.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,30 +144,40 @@ async function insertIntoES (modelName, dataset) {
144144
const chunked = _.chunk(dataset, config.get('ES.MAX_BULK_SIZE'))
145145
for (const ds of chunked) {
146146
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+
}
154159
}
155160
} else if (_.includes(_.keys(userResources), esResourceName)) {
156161
const userResource = userResources[esResourceName]
157162

158163
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+
}
167174
}
168175
}
169-
}
170-
})
176+
})
177+
} catch (e) {
178+
logger.error('ES, nexted mapping error.')
179+
logger.error(JSON.stringify(e))
180+
}
171181
userResource.mappingCreated = true
172182
}
173183

0 commit comments

Comments
 (0)