@lowdefy/connection-elasticsearch 4.0.0-alpha.26 → 4.0.0-alpha.29
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/package.json +6 -7
- package/dist/connections/Elasticsearch/Elasticsearch.js +0 -32
- package/dist/connections/Elasticsearch/ElasticsearchDelete/ElasticsearchDelete.js +0 -33
- package/dist/connections/Elasticsearch/ElasticsearchDelete/schema.js +0 -101
- package/dist/connections/Elasticsearch/ElasticsearchDeleteByQuery/ElasticsearchDeleteByQuery.js +0 -32
- package/dist/connections/Elasticsearch/ElasticsearchDeleteByQuery/schema.js +0 -245
- package/dist/connections/Elasticsearch/ElasticsearchIndex/ElasticsearchIndex.js +0 -34
- package/dist/connections/Elasticsearch/ElasticsearchIndex/schema.js +0 -114
- package/dist/connections/Elasticsearch/ElasticsearchSearch/ElasticsearchSearch.js +0 -57
- package/dist/connections/Elasticsearch/ElasticsearchSearch/schema.js +0 -452
- package/dist/connections/Elasticsearch/ElasticsearchUpdate/ElasticsearchUpdate.js +0 -33
- package/dist/connections/Elasticsearch/ElasticsearchUpdate/schema.js +0 -201
- package/dist/connections/Elasticsearch/ElasticsearchUpdateByQuery/ElasticsearchUpdateByQuery.js +0 -32
- package/dist/connections/Elasticsearch/ElasticsearchUpdateByQuery/schema.js +0 -254
- package/dist/connections/Elasticsearch/schema.js +0 -471
- package/dist/connections.js +0 -15
- package/dist/types.js +0 -19
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/ import { Client } from '@elastic/elasticsearch';
|
|
16
|
-
import { get } from '@lowdefy/helpers';
|
|
17
|
-
import schema from './schema.js';
|
|
18
|
-
async function ElasticsearchSearch({ request , connection }) {
|
|
19
|
-
const client = new Client(connection);
|
|
20
|
-
const { body: response } = await client.search({
|
|
21
|
-
...request,
|
|
22
|
-
index: request.index || connection.index
|
|
23
|
-
});
|
|
24
|
-
const rawHits = get(response, 'hits.hits', {
|
|
25
|
-
default: []
|
|
26
|
-
});
|
|
27
|
-
// Return the actual documents as hits.
|
|
28
|
-
// Map the documents to a more useful representation in our context:
|
|
29
|
-
// We return the results in the _source field as the main results
|
|
30
|
-
// and return all other fields in the _meta field.
|
|
31
|
-
const hits = rawHits.map((hit)=>{
|
|
32
|
-
const { _source , ..._meta } = hit;
|
|
33
|
-
return {
|
|
34
|
-
..._source,
|
|
35
|
-
_meta
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
response,
|
|
40
|
-
hits,
|
|
41
|
-
total: get(response, 'hits.total', {
|
|
42
|
-
default: {}
|
|
43
|
-
}),
|
|
44
|
-
maxScore: get(response, 'hits.max_score', {
|
|
45
|
-
default: 0
|
|
46
|
-
}),
|
|
47
|
-
aggregations: get(response, 'aggregations', {
|
|
48
|
-
default: {}
|
|
49
|
-
})
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
ElasticsearchSearch.schema = schema;
|
|
53
|
-
ElasticsearchSearch.meta = {
|
|
54
|
-
checkRead: true,
|
|
55
|
-
checkWrite: false
|
|
56
|
-
};
|
|
57
|
-
export default ElasticsearchSearch;
|
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/ export default {
|
|
16
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
-
title: 'Lowdefy Request Schema - ElasticsearchSearch',
|
|
18
|
-
type: 'object',
|
|
19
|
-
properties: {
|
|
20
|
-
body: {
|
|
21
|
-
type: 'object',
|
|
22
|
-
description: 'The search definition using the Query DSL.',
|
|
23
|
-
properties: {
|
|
24
|
-
query: {
|
|
25
|
-
$ref: '#/definitions/Query'
|
|
26
|
-
},
|
|
27
|
-
aggs: {
|
|
28
|
-
description: 'The aggregations to request for the search.',
|
|
29
|
-
type: 'object'
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
_source: {
|
|
34
|
-
description: 'True or false to return the _source field or not, or a list of fields to return.',
|
|
35
|
-
examples: [
|
|
36
|
-
[
|
|
37
|
-
'id',
|
|
38
|
-
'name'
|
|
39
|
-
],
|
|
40
|
-
'name',
|
|
41
|
-
true,
|
|
42
|
-
false
|
|
43
|
-
],
|
|
44
|
-
anyOf: [
|
|
45
|
-
{
|
|
46
|
-
items: {
|
|
47
|
-
type: 'string'
|
|
48
|
-
},
|
|
49
|
-
type: 'array'
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
type: 'string'
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
type: 'boolean'
|
|
56
|
-
},
|
|
57
|
-
]
|
|
58
|
-
},
|
|
59
|
-
_source_exclude: {
|
|
60
|
-
description: 'A list of fields to exclude from the returned _source field.',
|
|
61
|
-
examples: [
|
|
62
|
-
[
|
|
63
|
-
'id',
|
|
64
|
-
'name'
|
|
65
|
-
],
|
|
66
|
-
'name'
|
|
67
|
-
],
|
|
68
|
-
anyOf: [
|
|
69
|
-
{
|
|
70
|
-
items: {
|
|
71
|
-
type: 'string'
|
|
72
|
-
},
|
|
73
|
-
type: 'array'
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
type: 'string'
|
|
77
|
-
},
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
_source_excludes: {
|
|
81
|
-
description: 'A list of fields to exclude from the returned _source field.',
|
|
82
|
-
examples: [
|
|
83
|
-
[
|
|
84
|
-
'id',
|
|
85
|
-
'name'
|
|
86
|
-
],
|
|
87
|
-
'name'
|
|
88
|
-
],
|
|
89
|
-
anyOf: [
|
|
90
|
-
{
|
|
91
|
-
items: {
|
|
92
|
-
type: 'string'
|
|
93
|
-
},
|
|
94
|
-
type: 'array'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
type: 'string'
|
|
98
|
-
},
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
_source_include: {
|
|
102
|
-
description: 'A list of fields to extract and return from the _source field.',
|
|
103
|
-
examples: [
|
|
104
|
-
[
|
|
105
|
-
'id',
|
|
106
|
-
'name'
|
|
107
|
-
],
|
|
108
|
-
'name'
|
|
109
|
-
],
|
|
110
|
-
anyOf: [
|
|
111
|
-
{
|
|
112
|
-
items: {
|
|
113
|
-
type: 'string'
|
|
114
|
-
},
|
|
115
|
-
type: 'array'
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
type: 'string'
|
|
119
|
-
},
|
|
120
|
-
]
|
|
121
|
-
},
|
|
122
|
-
_source_includes: {
|
|
123
|
-
description: 'A list of fields to extract and return from the _source field.',
|
|
124
|
-
examples: [
|
|
125
|
-
[
|
|
126
|
-
'id',
|
|
127
|
-
'name'
|
|
128
|
-
],
|
|
129
|
-
'name'
|
|
130
|
-
],
|
|
131
|
-
anyOf: [
|
|
132
|
-
{
|
|
133
|
-
items: {
|
|
134
|
-
type: 'string'
|
|
135
|
-
},
|
|
136
|
-
type: 'array'
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
type: 'string'
|
|
140
|
-
},
|
|
141
|
-
]
|
|
142
|
-
},
|
|
143
|
-
allow_no_indices: {
|
|
144
|
-
description: 'Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified).',
|
|
145
|
-
type: 'boolean'
|
|
146
|
-
},
|
|
147
|
-
allow_partial_search_results: {
|
|
148
|
-
description: 'Indicate if an error should be returned if there is a partial search failure or timeout.',
|
|
149
|
-
type: 'boolean',
|
|
150
|
-
default: true
|
|
151
|
-
},
|
|
152
|
-
analyze_wildcard: {
|
|
153
|
-
description: 'Specify whether wildcard and prefix queries should be analyzed.',
|
|
154
|
-
type: 'boolean',
|
|
155
|
-
default: false
|
|
156
|
-
},
|
|
157
|
-
analyzer: {
|
|
158
|
-
description: 'The analyzer to use for the query string.',
|
|
159
|
-
type: 'string'
|
|
160
|
-
},
|
|
161
|
-
batched_reduce_size: {
|
|
162
|
-
description: 'The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.',
|
|
163
|
-
type: 'number',
|
|
164
|
-
default: 512
|
|
165
|
-
},
|
|
166
|
-
ccs_minimize_roundtrips: {
|
|
167
|
-
description: 'Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.',
|
|
168
|
-
type: 'boolean',
|
|
169
|
-
default: true
|
|
170
|
-
},
|
|
171
|
-
default_operator: {
|
|
172
|
-
description: 'The default operator for query string query (AND or OR).',
|
|
173
|
-
enum: [
|
|
174
|
-
'AND',
|
|
175
|
-
'OR'
|
|
176
|
-
],
|
|
177
|
-
type: 'string',
|
|
178
|
-
default: 'OR'
|
|
179
|
-
},
|
|
180
|
-
df: {
|
|
181
|
-
description: 'The field to use as default where no field prefix is given in the query string.',
|
|
182
|
-
type: 'string'
|
|
183
|
-
},
|
|
184
|
-
docvalue_fields: {
|
|
185
|
-
description: 'A comma-separated list of fields to return as the docvalue representation of a field for each hit.',
|
|
186
|
-
anyOf: [
|
|
187
|
-
{
|
|
188
|
-
items: {
|
|
189
|
-
type: 'string'
|
|
190
|
-
},
|
|
191
|
-
type: 'array'
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
type: 'string'
|
|
195
|
-
},
|
|
196
|
-
]
|
|
197
|
-
},
|
|
198
|
-
error_trace: {
|
|
199
|
-
description: 'Include the stack trace of returned errors.',
|
|
200
|
-
type: 'boolean'
|
|
201
|
-
},
|
|
202
|
-
expand_wildcards: {
|
|
203
|
-
description: 'Whether to expand wildcard expression to concrete indices that are open, closed or both.',
|
|
204
|
-
enum: [
|
|
205
|
-
'all',
|
|
206
|
-
'closed',
|
|
207
|
-
'hidden',
|
|
208
|
-
'none',
|
|
209
|
-
'open'
|
|
210
|
-
],
|
|
211
|
-
type: 'string',
|
|
212
|
-
default: 'open'
|
|
213
|
-
},
|
|
214
|
-
explain: {
|
|
215
|
-
description: 'Specify whether to return detailed information about score computation as part of a hit.',
|
|
216
|
-
type: 'boolean'
|
|
217
|
-
},
|
|
218
|
-
from: {
|
|
219
|
-
description: 'Starting offset.',
|
|
220
|
-
type: 'number',
|
|
221
|
-
default: 0
|
|
222
|
-
},
|
|
223
|
-
human: {
|
|
224
|
-
description: 'Return human readable values for statistics.',
|
|
225
|
-
type: 'boolean',
|
|
226
|
-
default: true
|
|
227
|
-
},
|
|
228
|
-
ignore_throttled: {
|
|
229
|
-
description: 'Whether specified concrete, expanded or aliased indices should be ignored when throttled.',
|
|
230
|
-
type: 'boolean'
|
|
231
|
-
},
|
|
232
|
-
ignore_unavailable: {
|
|
233
|
-
description: 'Whether specified concrete indices should be ignored when unavailable (missing or closed)',
|
|
234
|
-
type: 'boolean'
|
|
235
|
-
},
|
|
236
|
-
index: {
|
|
237
|
-
description: 'A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices.',
|
|
238
|
-
anyOf: [
|
|
239
|
-
{
|
|
240
|
-
items: {
|
|
241
|
-
type: 'string'
|
|
242
|
-
},
|
|
243
|
-
type: 'array'
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
type: 'string'
|
|
247
|
-
},
|
|
248
|
-
],
|
|
249
|
-
examples: [
|
|
250
|
-
'',
|
|
251
|
-
'_all',
|
|
252
|
-
'my_index'
|
|
253
|
-
]
|
|
254
|
-
},
|
|
255
|
-
lenient: {
|
|
256
|
-
description: 'Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.',
|
|
257
|
-
type: 'boolean'
|
|
258
|
-
},
|
|
259
|
-
max_concurrent_shard_requests: {
|
|
260
|
-
description: 'The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests.',
|
|
261
|
-
type: 'number',
|
|
262
|
-
default: 5
|
|
263
|
-
},
|
|
264
|
-
min_compatible_shard_node: {
|
|
265
|
-
description: 'The minimum compatible version that all shards involved in search should have for this request to be successful.',
|
|
266
|
-
type: 'string'
|
|
267
|
-
},
|
|
268
|
-
pre_filter_shard_size: {
|
|
269
|
-
description: 'A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.',
|
|
270
|
-
type: 'number'
|
|
271
|
-
},
|
|
272
|
-
preference: {
|
|
273
|
-
description: 'Specify the node or shard the operation should be performed on.',
|
|
274
|
-
type: 'string',
|
|
275
|
-
default: 'random'
|
|
276
|
-
},
|
|
277
|
-
pretty: {
|
|
278
|
-
description: 'Pretty format the returned JSON response.',
|
|
279
|
-
type: 'boolean'
|
|
280
|
-
},
|
|
281
|
-
q: {
|
|
282
|
-
description: 'Query in the Lucene query string syntax.',
|
|
283
|
-
type: 'string'
|
|
284
|
-
},
|
|
285
|
-
request_cache: {
|
|
286
|
-
description: 'Specify if request cache should be used for this request or not, defaults to index level setting.',
|
|
287
|
-
type: 'boolean'
|
|
288
|
-
},
|
|
289
|
-
rest_total_hits_as_int: {
|
|
290
|
-
description: 'Indicates whether hits.total should be rendered as an integer or an object in the rest search response.',
|
|
291
|
-
type: 'boolean'
|
|
292
|
-
},
|
|
293
|
-
routing: {
|
|
294
|
-
description: 'A comma-separated list of specific routing values.',
|
|
295
|
-
anyOf: [
|
|
296
|
-
{
|
|
297
|
-
items: {
|
|
298
|
-
type: 'string'
|
|
299
|
-
},
|
|
300
|
-
type: 'array'
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
type: 'string'
|
|
304
|
-
},
|
|
305
|
-
]
|
|
306
|
-
},
|
|
307
|
-
scroll: {
|
|
308
|
-
description: 'Specify how long a consistent view of the index should be maintained for scrolled search.',
|
|
309
|
-
type: 'string'
|
|
310
|
-
},
|
|
311
|
-
search_type: {
|
|
312
|
-
description: 'Search operation type.',
|
|
313
|
-
enum: [
|
|
314
|
-
'dfs_query_then_fetch',
|
|
315
|
-
'query_then_fetch'
|
|
316
|
-
],
|
|
317
|
-
type: 'string'
|
|
318
|
-
},
|
|
319
|
-
seq_no_primary_term: {
|
|
320
|
-
description: 'Specify whether to return sequence number and primary term of the last modification of each hit',
|
|
321
|
-
type: 'boolean'
|
|
322
|
-
},
|
|
323
|
-
size: {
|
|
324
|
-
description: 'Number of hits to return.',
|
|
325
|
-
type: 'number',
|
|
326
|
-
default: 10
|
|
327
|
-
},
|
|
328
|
-
sort: {
|
|
329
|
-
description: 'A comma-separated list of <field>:<direction> pairs.',
|
|
330
|
-
examples: [
|
|
331
|
-
'name:asc',
|
|
332
|
-
[
|
|
333
|
-
'rating:asc',
|
|
334
|
-
'created_at:desc'
|
|
335
|
-
]
|
|
336
|
-
],
|
|
337
|
-
anyOf: [
|
|
338
|
-
{
|
|
339
|
-
items: {
|
|
340
|
-
type: 'string'
|
|
341
|
-
},
|
|
342
|
-
type: 'array'
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
type: 'string'
|
|
346
|
-
},
|
|
347
|
-
]
|
|
348
|
-
},
|
|
349
|
-
source: {
|
|
350
|
-
description: 'The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.',
|
|
351
|
-
type: 'string'
|
|
352
|
-
},
|
|
353
|
-
stats: {
|
|
354
|
-
description: 'Specific tag of the request for logging and statistical purposes',
|
|
355
|
-
anyOf: [
|
|
356
|
-
{
|
|
357
|
-
items: {
|
|
358
|
-
type: 'string'
|
|
359
|
-
},
|
|
360
|
-
type: 'array'
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
type: 'string'
|
|
364
|
-
},
|
|
365
|
-
]
|
|
366
|
-
},
|
|
367
|
-
stored_fields: {
|
|
368
|
-
description: 'A comma-separated list of stored fields to return as part of a hit',
|
|
369
|
-
anyOf: [
|
|
370
|
-
{
|
|
371
|
-
items: {
|
|
372
|
-
type: 'string'
|
|
373
|
-
},
|
|
374
|
-
type: 'array'
|
|
375
|
-
},
|
|
376
|
-
{
|
|
377
|
-
type: 'string'
|
|
378
|
-
},
|
|
379
|
-
]
|
|
380
|
-
},
|
|
381
|
-
suggest_field: {
|
|
382
|
-
description: 'Specify which field to use for suggestions',
|
|
383
|
-
type: 'string'
|
|
384
|
-
},
|
|
385
|
-
suggest_mode: {
|
|
386
|
-
description: 'Specify suggest mode',
|
|
387
|
-
enum: [
|
|
388
|
-
'always',
|
|
389
|
-
'missing',
|
|
390
|
-
'popular'
|
|
391
|
-
],
|
|
392
|
-
type: 'string',
|
|
393
|
-
default: 'missing'
|
|
394
|
-
},
|
|
395
|
-
suggest_size: {
|
|
396
|
-
description: 'How many suggestions to return in response',
|
|
397
|
-
type: 'number'
|
|
398
|
-
},
|
|
399
|
-
suggest_text: {
|
|
400
|
-
description: 'The source text for which the suggestions should be returned.',
|
|
401
|
-
type: 'string'
|
|
402
|
-
},
|
|
403
|
-
terminate_after: {
|
|
404
|
-
description: 'The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.',
|
|
405
|
-
type: 'number'
|
|
406
|
-
},
|
|
407
|
-
timeout: {
|
|
408
|
-
description: 'Explicit operation timeout.',
|
|
409
|
-
type: 'string'
|
|
410
|
-
},
|
|
411
|
-
track_scores: {
|
|
412
|
-
description: 'Whether to calculate and return scores even if they are not used for sorting.',
|
|
413
|
-
type: 'boolean'
|
|
414
|
-
},
|
|
415
|
-
track_total_hits: {
|
|
416
|
-
description: 'Indicate if the number of documents that match the query should be tracked.',
|
|
417
|
-
type: 'boolean'
|
|
418
|
-
},
|
|
419
|
-
type: {
|
|
420
|
-
description: 'A comma-separated list of document types to search; leave empty to perform the operation on all types.',
|
|
421
|
-
anyOf: [
|
|
422
|
-
{
|
|
423
|
-
items: {
|
|
424
|
-
type: 'string'
|
|
425
|
-
},
|
|
426
|
-
type: 'array'
|
|
427
|
-
},
|
|
428
|
-
{
|
|
429
|
-
type: 'string'
|
|
430
|
-
},
|
|
431
|
-
]
|
|
432
|
-
},
|
|
433
|
-
typed_keys: {
|
|
434
|
-
description: 'Specify whether aggregation and suggester names should be prefixed by their respective types in the response.',
|
|
435
|
-
type: 'boolean'
|
|
436
|
-
},
|
|
437
|
-
version: {
|
|
438
|
-
description: 'Specify whether to return document version as part of a hit',
|
|
439
|
-
type: 'boolean'
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
definitions: {
|
|
443
|
-
Query: {
|
|
444
|
-
description: 'A query expressed in the Elasticsearch query DSL. See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html.',
|
|
445
|
-
type: 'object',
|
|
446
|
-
additionalProperties: true
|
|
447
|
-
}
|
|
448
|
-
},
|
|
449
|
-
errorMessage: {
|
|
450
|
-
type: 'ElasticsearchSearch request properties should be an object.'
|
|
451
|
-
}
|
|
452
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/ import { Client } from '@elastic/elasticsearch';
|
|
16
|
-
import schema from './schema.js';
|
|
17
|
-
async function ElasticsearchUpdate({ request , connection }) {
|
|
18
|
-
const client = new Client(connection);
|
|
19
|
-
const { body: response } = await client.update({
|
|
20
|
-
...request,
|
|
21
|
-
index: request.index || connection.index
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
id: response._id,
|
|
25
|
-
response
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
ElasticsearchUpdate.schema = schema;
|
|
29
|
-
ElasticsearchUpdate.meta = {
|
|
30
|
-
checkRead: false,
|
|
31
|
-
checkWrite: true
|
|
32
|
-
};
|
|
33
|
-
export default ElasticsearchUpdate;
|