File tree 7 files changed +42
-7
lines changed
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')
11
11
const client = new Client({ node: 'http://localhost:9200' })
12
12
13
13
async function run () {
14
- await client.bulk({
14
+ const { body: bulkResponse } = await client.bulk({
15
15
refresh: true,
16
16
body: [
17
17
// operation to perform
@@ -36,6 +36,11 @@ async function run () {
36
36
]
37
37
})
38
38
39
+ if (bulkResponse.errors) {
40
+ console.log(bulkResponse)
41
+ process.exit(1)
42
+ }
43
+
39
44
// Let's search!
40
45
const { body } = await client.search({
41
46
index: 'game-of-thrones',
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const { Client } = require('@elastic/elasticsearch')
12
12
const client = new Client({ node: 'http://localhost:9200' })
13
13
14
14
async function run () {
15
- await client.bulk({
15
+ const { body: bulkResponse } = await client.bulk({
16
16
// here we are forcing an index refresh,
17
17
// otherwise we will not get any result
18
18
// in the consequent search
@@ -40,6 +40,11 @@ async function run () {
40
40
]
41
41
})
42
42
43
+ if (bulkResponse.errors) {
44
+ console.log(bulkResponse)
45
+ process.exit(1)
46
+ }
47
+
43
48
// Let's search!
44
49
const { body } = await client.search({
45
50
index: 'game-of-thrones',
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const { Client } = require('@elastic/elasticsearch')
10
10
const client = new Client({ node: 'http://localhost:9200' })
11
11
12
12
async function run () {
13
- await client.bulk({
13
+ const { body: bulkResponse } = await client.bulk({
14
14
refresh: true,
15
15
body: [
16
16
// operation to perform
@@ -35,6 +35,11 @@ async function run () {
35
35
]
36
36
})
37
37
38
+ if (bulkResponse.errors) {
39
+ console.log(bulkResponse)
40
+ process.exit(1)
41
+ }
42
+
38
43
// Let's search!
39
44
const { body } = await client.search({
40
45
index: 'game-of-thrones',
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ const { Client } = require('@elastic/elasticsearch')
11
11
const client = new Client({ node: 'http://localhost:9200' })
12
12
13
13
async function run () {
14
- await client.bulk({
14
+ const { body: bulkResponse } = await client.bulk({
15
15
refresh: true,
16
16
body: [
17
17
{ index: { _index: 'game-of-thrones' } },
@@ -34,6 +34,11 @@ async function run () {
34
34
]
35
35
})
36
36
37
+ if (bulkResponse.errors) {
38
+ console.log(bulkResponse)
39
+ process.exit(1)
40
+ }
41
+
37
42
const { body } = await client.msearch({
38
43
body: [
39
44
{ index: 'game-of-thrones' },
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ async function run () {
21
21
const responseQueue = []
22
22
23
23
// Let's index some data!
24
- await client.bulk({
24
+ const { body: bulkResponse } = await client.bulk({
25
25
// here we are forcing an index refresh,
26
26
// otherwise we will not get any result
27
27
// in the consequent search
@@ -49,6 +49,11 @@ async function run () {
49
49
]
50
50
})
51
51
52
+ if (bulkResponse.errors) {
53
+ console.log(bulkResponse)
54
+ process.exit(1)
55
+ }
56
+
52
57
// start things off by searching, setting a scroll timeout, and pushing
53
58
// our first response into the queue to be processed
54
59
const response = await client.search({
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ const { Client } = require('@elastic/elasticsearch')
14
14
const client = new Client({ node: 'http://localhost:9200' })
15
15
16
16
async function run () {
17
- await client.bulk({
17
+ const { body: bulkResponse } = await client.bulk({
18
18
refresh: true,
19
19
body: [
20
20
{ index: { _index: 'game-of-thrones' } },
@@ -37,6 +37,11 @@ async function run () {
37
37
]
38
38
})
39
39
40
+ if (bulkResponse.errors) {
41
+ console.log(bulkResponse)
42
+ process.exit(1)
43
+ }
44
+
40
45
const { body } = await client.search({
41
46
index: 'game-of-thrones',
42
47
body: {
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ const { Client } = require('@elastic/elasticsearch')
16
16
const client = new Client({ node: 'http://localhost:9200' })
17
17
18
18
async function run () {
19
- await client.bulk({
19
+ const { body: bulkResponse } = await client.bulk({
20
20
refresh: true,
21
21
body: [
22
22
{ index: { _index: 'game-of-thrones' } },
@@ -39,6 +39,11 @@ async function run () {
39
39
]
40
40
})
41
41
42
+ if (bulkResponse.errors) {
43
+ console.log(bulkResponse)
44
+ process.exit(1)
45
+ }
46
+
42
47
const { body } = await client.transport.request({
43
48
method: 'POST',
44
49
path: '/game-of-thrones/_search',
You can’t perform that action at this time.
0 commit comments