File tree Expand file tree Collapse file tree 7 files changed +42
-7
lines changed Expand file tree Collapse file tree 7 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const { Client } = require('@elastic/elasticsearch')
1111const client = new Client({ node: 'http://localhost:9200' })
1212
1313async function run () {
14- await client.bulk({
14+ const { body: bulkResponse } = await client.bulk({
1515 refresh: true,
1616 body: [
1717 // operation to perform
@@ -36,6 +36,11 @@ async function run () {
3636 ]
3737 })
3838
39+ if (bulkResponse.errors) {
40+ console.log(bulkResponse)
41+ process.exit(1)
42+ }
43+
3944 // Let's search!
4045 const { body } = await client.search({
4146 index: 'game-of-thrones',
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const { Client } = require('@elastic/elasticsearch')
1212const client = new Client({ node: 'http://localhost:9200' })
1313
1414async function run () {
15- await client.bulk({
15+ const { body: bulkResponse } = await client.bulk({
1616 // here we are forcing an index refresh,
1717 // otherwise we will not get any result
1818 // in the consequent search
@@ -40,6 +40,11 @@ async function run () {
4040 ]
4141 })
4242
43+ if (bulkResponse.errors) {
44+ console.log(bulkResponse)
45+ process.exit(1)
46+ }
47+
4348 // Let's search!
4449 const { body } = await client.search({
4550 index: 'game-of-thrones',
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const { Client } = require('@elastic/elasticsearch')
1010const client = new Client({ node: 'http://localhost:9200' })
1111
1212async function run () {
13- await client.bulk({
13+ const { body: bulkResponse } = await client.bulk({
1414 refresh: true,
1515 body: [
1616 // operation to perform
@@ -35,6 +35,11 @@ async function run () {
3535 ]
3636 })
3737
38+ if (bulkResponse.errors) {
39+ console.log(bulkResponse)
40+ process.exit(1)
41+ }
42+
3843 // Let's search!
3944 const { body } = await client.search({
4045 index: 'game-of-thrones',
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const { Client } = require('@elastic/elasticsearch')
1111const client = new Client({ node: 'http://localhost:9200' })
1212
1313async function run () {
14- await client.bulk({
14+ const { body: bulkResponse } = await client.bulk({
1515 refresh: true,
1616 body: [
1717 { index: { _index: 'game-of-thrones' } },
@@ -34,6 +34,11 @@ async function run () {
3434 ]
3535 })
3636
37+ if (bulkResponse.errors) {
38+ console.log(bulkResponse)
39+ process.exit(1)
40+ }
41+
3742 const { body } = await client.msearch({
3843 body: [
3944 { index: 'game-of-thrones' },
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ async function run () {
2121 const responseQueue = []
2222
2323 // Let's index some data!
24- await client.bulk({
24+ const { body: bulkResponse } = await client.bulk({
2525 // here we are forcing an index refresh,
2626 // otherwise we will not get any result
2727 // in the consequent search
@@ -49,6 +49,11 @@ async function run () {
4949 ]
5050 })
5151
52+ if (bulkResponse.errors) {
53+ console.log(bulkResponse)
54+ process.exit(1)
55+ }
56+
5257 // start things off by searching, setting a scroll timeout, and pushing
5358 // our first response into the queue to be processed
5459 const response = await client.search({
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ const { Client } = require('@elastic/elasticsearch')
1414const client = new Client({ node: 'http://localhost:9200' })
1515
1616async function run () {
17- await client.bulk({
17+ const { body: bulkResponse } = await client.bulk({
1818 refresh: true,
1919 body: [
2020 { index: { _index: 'game-of-thrones' } },
@@ -37,6 +37,11 @@ async function run () {
3737 ]
3838 })
3939
40+ if (bulkResponse.errors) {
41+ console.log(bulkResponse)
42+ process.exit(1)
43+ }
44+
4045 const { body } = await client.search({
4146 index: 'game-of-thrones',
4247 body: {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ const { Client } = require('@elastic/elasticsearch')
1616const client = new Client({ node: 'http://localhost:9200' })
1717
1818async function run () {
19- await client.bulk({
19+ const { body: bulkResponse } = await client.bulk({
2020 refresh: true,
2121 body: [
2222 { index: { _index: 'game-of-thrones' } },
@@ -39,6 +39,11 @@ async function run () {
3939 ]
4040 })
4141
42+ if (bulkResponse.errors) {
43+ console.log(bulkResponse)
44+ process.exit(1)
45+ }
46+
4247 const { body } = await client.transport.request({
4348 method: 'POST',
4449 path: '/game-of-thrones/_search',
You can’t perform that action at this time.
0 commit comments