aws-v3-sdk 1.0.23 → 1.0.24
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/sendGetRequest.js +41 -17
- package/package.json +1 -1
|
@@ -63,8 +63,12 @@ exports.sendGetRequest = async (index, query, from, size, sort, _source) => {
|
|
|
63
63
|
})
|
|
64
64
|
resolve({ items: mappedData, data: mappedData, totalCount })
|
|
65
65
|
}).catch(err => {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
if (err) {
|
|
67
|
+
logger.error('ES sendGetRequest Error', { err })
|
|
68
|
+
reject(err)
|
|
69
|
+
} else {
|
|
70
|
+
resolve({ items: [], data: [], totalCount: 0 })
|
|
71
|
+
}
|
|
68
72
|
})
|
|
69
73
|
})
|
|
70
74
|
}
|
|
@@ -72,25 +76,37 @@ exports.sendGetRequest = async (index, query, from, size, sort, _source) => {
|
|
|
72
76
|
exports.sendGetRequestCallback = async (index, query, from, size, sort, callback) => {
|
|
73
77
|
const client = await getClient()
|
|
74
78
|
return new Promise((resolve, reject) => {
|
|
75
|
-
|
|
79
|
+
const body = {}
|
|
80
|
+
if (query) {
|
|
81
|
+
body.query = query
|
|
82
|
+
}
|
|
76
83
|
if (sort) {
|
|
77
|
-
body =
|
|
84
|
+
body.sort = sort
|
|
78
85
|
}
|
|
79
|
-
|
|
86
|
+
const options = {
|
|
80
87
|
index,
|
|
81
|
-
from,
|
|
82
|
-
size,
|
|
83
88
|
body
|
|
84
|
-
}
|
|
89
|
+
}
|
|
90
|
+
if (from) {
|
|
91
|
+
options.from = from
|
|
92
|
+
}
|
|
93
|
+
if (size) {
|
|
94
|
+
options.size = size
|
|
95
|
+
}
|
|
96
|
+
client.search(options).then(response => {
|
|
85
97
|
const data = response.body.hits.hits
|
|
86
98
|
const totalCount = response.body.hits.total
|
|
87
99
|
const mappedData = data.map(item => {
|
|
88
100
|
return item._source
|
|
89
101
|
})
|
|
90
102
|
callback(null, { items: mappedData, data: mappedData, totalCount })
|
|
91
|
-
}).catch(
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
}).catch(err => {
|
|
104
|
+
if (err) {
|
|
105
|
+
logger.error('ES Error', { err })
|
|
106
|
+
reject(err)
|
|
107
|
+
} else {
|
|
108
|
+
resolve({ items: [], data: [], totalCount: 0 })
|
|
109
|
+
}
|
|
94
110
|
})
|
|
95
111
|
})
|
|
96
112
|
}
|
|
@@ -104,9 +120,13 @@ exports.getCount = async (index, query) => {
|
|
|
104
120
|
}).then(response => {
|
|
105
121
|
const data = response.body
|
|
106
122
|
resolve({ data })
|
|
107
|
-
}).catch(
|
|
108
|
-
|
|
109
|
-
|
|
123
|
+
}).catch(err => {
|
|
124
|
+
if (err) {
|
|
125
|
+
logger.error('ES Error', { err })
|
|
126
|
+
reject(err)
|
|
127
|
+
} else {
|
|
128
|
+
resolve({ items: [], data: [], totalCount: 0 })
|
|
129
|
+
}
|
|
110
130
|
})
|
|
111
131
|
})
|
|
112
132
|
}
|
|
@@ -119,9 +139,13 @@ exports.multiSearch = async (query) => {
|
|
|
119
139
|
body
|
|
120
140
|
}).then(response => {
|
|
121
141
|
resolve(response)
|
|
122
|
-
}).catch(
|
|
123
|
-
|
|
124
|
-
|
|
142
|
+
}).catch(err => {
|
|
143
|
+
if (err) {
|
|
144
|
+
logger.error('ES Error', { err })
|
|
145
|
+
reject(err)
|
|
146
|
+
} else {
|
|
147
|
+
resolve({ items: [], data: [], totalCount: 0 })
|
|
148
|
+
}
|
|
125
149
|
})
|
|
126
150
|
})
|
|
127
151
|
}
|