Handle bulk errors in examples
This commit is contained in:
@ -10,7 +10,7 @@ const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({ node: 'http://localhost:9200' })
|
||||
|
||||
async function run () {
|
||||
await client.bulk({
|
||||
const { body: bulkResponse } = await client.bulk({
|
||||
refresh: true,
|
||||
body: [
|
||||
// operation to perform
|
||||
@ -35,6 +35,11 @@ async function run () {
|
||||
]
|
||||
})
|
||||
|
||||
if (bulkResponse.errors) {
|
||||
console.log(bulkResponse)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Let's search!
|
||||
const { body } = await client.search({
|
||||
index: 'game-of-thrones',
|
||||
|
||||
Reference in New Issue
Block a user