diff --git a/docs/examples/asStream.asciidoc b/docs/examples/asStream.asciidoc index 648f2cd06..d449fca1a 100644 --- a/docs/examples/asStream.asciidoc +++ b/docs/examples/asStream.asciidoc @@ -11,7 +11,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 @@ -36,6 +36,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', diff --git a/docs/examples/bulk.asciidoc b/docs/examples/bulk.asciidoc index b7de4d37f..7d87b7af1 100644 --- a/docs/examples/bulk.asciidoc +++ b/docs/examples/bulk.asciidoc @@ -12,7 +12,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({ // here we are forcing an index refresh, // otherwise we will not get any result // in the consequent search @@ -40,6 +40,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', diff --git a/docs/examples/ignore.asciidoc b/docs/examples/ignore.asciidoc index d747daae7..c7a40583d 100644 --- a/docs/examples/ignore.asciidoc +++ b/docs/examples/ignore.asciidoc @@ -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', diff --git a/docs/examples/msearch.asciidoc b/docs/examples/msearch.asciidoc index 9dbdec1ff..9cf2d79cd 100644 --- a/docs/examples/msearch.asciidoc +++ b/docs/examples/msearch.asciidoc @@ -11,7 +11,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' } }, @@ -34,6 +34,11 @@ async function run () { ] }) + if (bulkResponse.errors) { + console.log(bulkResponse) + process.exit(1) + } + const { body } = await client.msearch({ body: [ { index: 'game-of-thrones' }, diff --git a/docs/examples/scroll.asciidoc b/docs/examples/scroll.asciidoc index d07b7449f..84b5aed83 100644 --- a/docs/examples/scroll.asciidoc +++ b/docs/examples/scroll.asciidoc @@ -21,7 +21,7 @@ async function run () { const responseQueue = [] // Let's index some data! - await client.bulk({ + const { body: bulkResponse } = await client.bulk({ // here we are forcing an index refresh, // otherwise we will not get any result // in the consequent search @@ -49,6 +49,11 @@ async function run () { ] }) + if (bulkResponse.errors) { + console.log(bulkResponse) + process.exit(1) + } + // start things off by searching, setting a scroll timeout, and pushing // our first response into the queue to be processed const response = await client.search({ diff --git a/docs/examples/suggest.asciidoc b/docs/examples/suggest.asciidoc index d252f6803..004e51648 100644 --- a/docs/examples/suggest.asciidoc +++ b/docs/examples/suggest.asciidoc @@ -14,7 +14,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' } }, @@ -37,6 +37,11 @@ async function run () { ] }) + if (bulkResponse.errors) { + console.log(bulkResponse) + process.exit(1) + } + const { body } = await client.search({ index: 'game-of-thrones', body: { diff --git a/docs/examples/transport.request.asciidoc b/docs/examples/transport.request.asciidoc index 8689a7363..5cd89aa76 100644 --- a/docs/examples/transport.request.asciidoc +++ b/docs/examples/transport.request.asciidoc @@ -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',