aws-v3-sdk 1.0.11 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es-handler/es-wrapper.js +30 -18
- package/es-handler/sendGetRequest.js +5 -1
- package/package.json +1 -1
package/es-handler/es-wrapper.js
CHANGED
|
@@ -32,23 +32,35 @@ const getClient = async () => {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
exports.sendReqToES = async (method, index, type, id, data) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
try {
|
|
36
|
+
const client = await getClient()
|
|
37
|
+
if (method === 'DELETE') {
|
|
38
|
+
const response = await client.delete({
|
|
39
|
+
index,
|
|
40
|
+
type,
|
|
41
|
+
id
|
|
42
|
+
})
|
|
43
|
+
return response.body
|
|
44
|
+
} else if (method === 'UPDATE') {
|
|
45
|
+
const response = await client.update({
|
|
46
|
+
id,
|
|
47
|
+
index,
|
|
48
|
+
type,
|
|
49
|
+
body: data,
|
|
50
|
+
refresh: true
|
|
51
|
+
})
|
|
52
|
+
return response.body
|
|
53
|
+
} else {
|
|
54
|
+
const response = await client.index({
|
|
55
|
+
id,
|
|
56
|
+
index,
|
|
57
|
+
type,
|
|
58
|
+
body: data,
|
|
59
|
+
refresh: true
|
|
60
|
+
})
|
|
61
|
+
return response.body
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
return error
|
|
53
65
|
}
|
|
54
66
|
}
|
|
@@ -33,12 +33,16 @@ const getClient = async () => {
|
|
|
33
33
|
exports.sendGetRequest = async (index, query, from, size, sort, _source) => {
|
|
34
34
|
const client = await getClient()
|
|
35
35
|
return new Promise((resolve, reject) => {
|
|
36
|
+
let body = { query }
|
|
37
|
+
if (sort) {
|
|
38
|
+
body = { query, sort }
|
|
39
|
+
}
|
|
36
40
|
client.search({
|
|
37
41
|
index,
|
|
38
42
|
from,
|
|
39
43
|
size,
|
|
40
44
|
_source,
|
|
41
|
-
body
|
|
45
|
+
body
|
|
42
46
|
}).then(response => {
|
|
43
47
|
const data = response.body.hits.hits
|
|
44
48
|
const totalCount = response.body.hits.total
|