Handle bulk errors in examples

This commit is contained in:
delvedor
2019-04-01 09:08:32 +02:00
parent 74c37e5b2d
commit ca0b33a2b0
7 changed files with 42 additions and 7 deletions

View File

@ -16,7 +16,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: [
{ index: { _index: 'game-of-thrones' } },
@ -39,6 +39,11 @@ async function run () {
]
})
if (bulkResponse.errors) {
console.log(bulkResponse)
process.exit(1)
}
const { body } = await client.transport.request({
method: 'POST',
path: '/game-of-thrones/_search',