@lowdefy/connection-elasticsearch 4.0.0-alpha.1 → 4.0.0-alpha.10

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.
Files changed (29) hide show
  1. package/dist/connections/Elasticsearch/Elasticsearch.js +3 -4
  2. package/dist/connections/Elasticsearch/ElasticsearchDelete/ElasticsearchDelete.js +9 -3
  3. package/dist/connections/Elasticsearch/ElasticsearchDelete/schema.js +101 -0
  4. package/dist/connections/Elasticsearch/ElasticsearchDeleteByQuery/ElasticsearchDeleteByQuery.js +9 -3
  5. package/dist/connections/Elasticsearch/ElasticsearchDeleteByQuery/schema.js +245 -0
  6. package/dist/connections/Elasticsearch/ElasticsearchIndex/ElasticsearchIndex.js +9 -3
  7. package/dist/connections/Elasticsearch/ElasticsearchIndex/schema.js +114 -0
  8. package/dist/connections/Elasticsearch/ElasticsearchSearch/ElasticsearchSearch.js +11 -8
  9. package/dist/connections/Elasticsearch/ElasticsearchSearch/schema.js +452 -0
  10. package/dist/connections/Elasticsearch/ElasticsearchUpdate/ElasticsearchUpdate.js +9 -3
  11. package/dist/connections/Elasticsearch/ElasticsearchUpdate/schema.js +201 -0
  12. package/dist/connections/Elasticsearch/ElasticsearchUpdateByQuery/ElasticsearchUpdateByQuery.js +9 -3
  13. package/dist/connections/Elasticsearch/ElasticsearchUpdateByQuery/schema.js +254 -0
  14. package/dist/connections/Elasticsearch/schema.js +471 -0
  15. package/dist/{connections/Elasticsearch/ElasticsearchIndex/index.js → connections.js} +2 -11
  16. package/dist/{connections/Elasticsearch/ElasticsearchDelete/index.js → types.js} +7 -11
  17. package/package.json +13 -12
  18. package/dist/connections/Elasticsearch/ElasticsearchDelete/ElasticsearchDelete.json +0 -87
  19. package/dist/connections/Elasticsearch/ElasticsearchDeleteByQuery/ElasticsearchDeleteByQuery.json +0 -231
  20. package/dist/connections/Elasticsearch/ElasticsearchDeleteByQuery/index.js +0 -24
  21. package/dist/connections/Elasticsearch/ElasticsearchIndex/ElasticsearchIndex.json +0 -100
  22. package/dist/connections/Elasticsearch/ElasticsearchSchema.json +0 -457
  23. package/dist/connections/Elasticsearch/ElasticsearchSearch/ElasticsearchSearch.json +0 -380
  24. package/dist/connections/Elasticsearch/ElasticsearchSearch/index.js +0 -24
  25. package/dist/connections/Elasticsearch/ElasticsearchUpdate/ElasticsearchUpdate.json +0 -187
  26. package/dist/connections/Elasticsearch/ElasticsearchUpdate/index.js +0 -24
  27. package/dist/connections/Elasticsearch/ElasticsearchUpdateByQuery/ElasticsearchUpdateByQuery.json +0 -240
  28. package/dist/connections/Elasticsearch/ElasticsearchUpdateByQuery/index.js +0 -24
  29. package/dist/index.js +0 -7
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -18,10 +18,9 @@ import ElasticsearchIndex from './ElasticsearchIndex/ElasticsearchIndex.js';
18
18
  import ElasticsearchSearch from './ElasticsearchSearch/ElasticsearchSearch.js';
19
19
  import ElasticsearchUpdate from './ElasticsearchUpdate/ElasticsearchUpdate.js';
20
20
  import ElasticsearchUpdateByQuery from './ElasticsearchUpdateByQuery/ElasticsearchUpdateByQuery.js';
21
+ import schema from './schema.js';
21
22
  export default {
22
- import: {
23
- schema: 'connections/Elasticsearch/ElasticsearchSchema.json'
24
- },
23
+ schema,
25
24
  requests: {
26
25
  ElasticsearchDelete,
27
26
  ElasticsearchDeleteByQuery,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,8 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { Client } from '@elastic/elasticsearch';
16
- async function elasticsearchDelete({ request , connection }) {
16
+ import schema from './schema.js';
17
+ async function ElasticsearchDelete({ request , connection }) {
17
18
  const client = new Client(connection);
18
19
  const { body: response } = await client.delete({
19
20
  ...request,
@@ -24,4 +25,9 @@ async function elasticsearchDelete({ request , connection }) {
24
25
  response
25
26
  };
26
27
  }
27
- export default elasticsearchDelete;
28
+ ElasticsearchDelete.schema = schema;
29
+ ElasticsearchDelete.meta = {
30
+ checkRead: false,
31
+ checkWrite: true
32
+ };
33
+ export default ElasticsearchDelete;
@@ -0,0 +1,101 @@
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 - ElasticsearchDelete',
18
+ type: 'object',
19
+ description: 'Removes a JSON document from the specified index.',
20
+ required: [
21
+ 'id'
22
+ ],
23
+ properties: {
24
+ id: {
25
+ anyOf: [
26
+ {
27
+ type: 'string'
28
+ },
29
+ {
30
+ type: 'number'
31
+ },
32
+ ],
33
+ description: 'Unique identifier for the document.'
34
+ },
35
+ index: {
36
+ type: 'string',
37
+ description: 'The name of the index.'
38
+ },
39
+ if_seq_no: {
40
+ type: 'integer',
41
+ description: 'Only perform the delete operation if the last operation that has changed the document has the specified sequence number.'
42
+ },
43
+ if_primary_term: {
44
+ type: 'integer',
45
+ description: 'Only perform the delete operation if the last operation that has changed the document has the specified primary term.'
46
+ },
47
+ refresh: {
48
+ anyOf: [
49
+ {
50
+ type: 'string'
51
+ },
52
+ {
53
+ type: 'boolean'
54
+ },
55
+ ],
56
+ description: 'If true, Elasticsearch refreshes the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false do nothing with refreshes. Valid values: true, false, wait_for. Default: false.',
57
+ enum: [
58
+ 'true',
59
+ 'false',
60
+ true,
61
+ false,
62
+ 'wait_for'
63
+ ],
64
+ default: false
65
+ },
66
+ routing: {
67
+ description: 'Custom value used to route operations to a specific shard.',
68
+ type: 'string'
69
+ },
70
+ timeout: {
71
+ type: 'string',
72
+ description: 'Period to wait for active shards. Defaults to 1m (one minute).',
73
+ default: '1m'
74
+ },
75
+ version: {
76
+ description: 'Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.',
77
+ type: 'integer'
78
+ },
79
+ version_type: {
80
+ type: 'string',
81
+ description: 'Specific version type.',
82
+ enum: [
83
+ 'internal',
84
+ 'external',
85
+ 'external_gte',
86
+ 'force'
87
+ ]
88
+ },
89
+ wait_for_active_shards: {
90
+ type: 'string',
91
+ description: 'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.',
92
+ default: '1'
93
+ }
94
+ },
95
+ errorMessage: {
96
+ type: 'ElasticsearchDelete request properties should be an object.',
97
+ required: {
98
+ id: 'ElasticsearchDelete request should have required property "id".'
99
+ }
100
+ }
101
+ };
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,8 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { Client } from '@elastic/elasticsearch';
16
- async function elasticsearchDeleteByQuery({ request , connection }) {
16
+ import schema from './schema.js';
17
+ async function ElasticsearchDeleteByQuery({ request , connection }) {
17
18
  const client = new Client(connection);
18
19
  const { body: response } = await client.deleteByQuery({
19
20
  ...request,
@@ -23,4 +24,9 @@ async function elasticsearchDeleteByQuery({ request , connection }) {
23
24
  response
24
25
  };
25
26
  }
26
- export default elasticsearchDeleteByQuery;
27
+ ElasticsearchDeleteByQuery.schema = schema;
28
+ ElasticsearchDeleteByQuery.meta = {
29
+ checkRead: false,
30
+ checkWrite: true
31
+ };
32
+ export default ElasticsearchDeleteByQuery;
@@ -0,0 +1,245 @@
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 - ElasticsearchDeleteByQuery',
18
+ type: 'object',
19
+ description: 'Deletes documents that match the specified query.',
20
+ properties: {
21
+ index: {
22
+ type: 'string',
23
+ description: 'The name of the index.'
24
+ },
25
+ allow_no_indices: {
26
+ type: 'boolean',
27
+ description: 'If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.',
28
+ default: true
29
+ },
30
+ analyzer: {
31
+ description: 'The analyzer to use for the query string.',
32
+ type: 'string'
33
+ },
34
+ analyze_wildcard: {
35
+ description: 'Specify whether wildcard and prefix queries should be analyzed.',
36
+ type: 'boolean',
37
+ default: false
38
+ },
39
+ conflicts: {
40
+ type: 'string',
41
+ enum: [
42
+ 'abort',
43
+ 'proceed'
44
+ ],
45
+ description: 'What to do if delete by query hits version conflicts: abort or proceed. Defaults to abort.',
46
+ default: 'abort'
47
+ },
48
+ default_operator: {
49
+ description: 'The default operator for query string query (AND or OR).',
50
+ enum: [
51
+ 'AND',
52
+ 'OR'
53
+ ],
54
+ type: 'string',
55
+ default: 'OR'
56
+ },
57
+ df: {
58
+ description: 'The field to use as default where no field prefix is given in the query string.',
59
+ type: 'string'
60
+ },
61
+ expand_wildcards: {
62
+ description: 'Whether to expand wildcard expression to concrete indices that are open, closed or both.',
63
+ enum: [
64
+ 'all',
65
+ 'closed',
66
+ 'hidden',
67
+ 'none',
68
+ 'open'
69
+ ],
70
+ type: 'string',
71
+ default: 'open'
72
+ },
73
+ from: {
74
+ description: 'Starting offset.',
75
+ type: 'number',
76
+ default: 0
77
+ },
78
+ ignore_unavailable: {
79
+ description: 'Whether specified concrete indices should be ignored when unavailable (missing or closed)',
80
+ type: 'boolean'
81
+ },
82
+ lenient: {
83
+ description: 'Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.',
84
+ type: 'boolean'
85
+ },
86
+ max_docs: {
87
+ type: 'integer',
88
+ description: 'Maximum number of documents to process. Defaults to all documents.'
89
+ },
90
+ preference: {
91
+ description: 'Specify the node or shard the operation should be performed on.',
92
+ type: 'string',
93
+ default: 'random'
94
+ },
95
+ pretty: {
96
+ description: 'Pretty format the returned JSON response.',
97
+ type: 'boolean'
98
+ },
99
+ q: {
100
+ description: 'Query in the Lucene query string syntax.',
101
+ type: 'string'
102
+ },
103
+ request_cache: {
104
+ description: 'Specify if request cache should be used for this request or not, defaults to index level setting.',
105
+ type: 'boolean'
106
+ },
107
+ refresh: {
108
+ anyOf: [
109
+ {
110
+ type: 'string'
111
+ },
112
+ {
113
+ type: 'boolean'
114
+ },
115
+ ],
116
+ description: 'If true, Elasticsearch refreshes all shards involved in the delete by query after the request completes. Defaults to false.',
117
+ enum: [
118
+ 'true',
119
+ 'false',
120
+ true,
121
+ false,
122
+ 'wait_for'
123
+ ],
124
+ default: false
125
+ },
126
+ requests_per_second: {
127
+ type: 'integer',
128
+ description: 'The throttle for this request in sub-requests per second. Defaults to -1 (no throttle).',
129
+ default: -1
130
+ },
131
+ routing: {
132
+ type: 'string',
133
+ description: 'Custom value used to route operations to a specific shard.'
134
+ },
135
+ scroll: {
136
+ type: 'string',
137
+ description: 'Period to retain the search context for scrolling. See Scroll search results.'
138
+ },
139
+ scroll_size: {
140
+ type: 'integer',
141
+ description: 'Size of the scroll request that powers the operation. Defaults to 1000.',
142
+ default: 1000
143
+ },
144
+ search_type: {
145
+ description: 'Search operation type.',
146
+ enum: [
147
+ 'dfs_query_then_fetch',
148
+ 'query_then_fetch'
149
+ ],
150
+ type: 'string'
151
+ },
152
+ search_timeout: {
153
+ type: 'string',
154
+ description: 'Explicit timeout for each search request. Defaults to no timeout.'
155
+ },
156
+ slices: {
157
+ type: 'integer',
158
+ description: "The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks."
159
+ },
160
+ sort: {
161
+ description: 'A comma-separated list of <field>:<direction> pairs.',
162
+ examples: [
163
+ 'name:asc',
164
+ [
165
+ 'rating:asc',
166
+ 'created_at:desc'
167
+ ]
168
+ ],
169
+ anyOf: [
170
+ {
171
+ items: {
172
+ type: 'string'
173
+ },
174
+ type: 'array'
175
+ },
176
+ {
177
+ type: 'string'
178
+ },
179
+ ]
180
+ },
181
+ _source: {
182
+ anyOf: [
183
+ {
184
+ type: 'boolean'
185
+ },
186
+ {
187
+ type: 'array'
188
+ },
189
+ ],
190
+ items: {
191
+ type: 'string'
192
+ },
193
+ description: 'True or false to return the _source field or not, or a list of fields to return.'
194
+ },
195
+ _source_excludes: {
196
+ type: 'array',
197
+ items: {
198
+ type: 'string'
199
+ },
200
+ description: 'A comma-separated list of source fields to exclude from the response.\n\nYou can also use this parameter to exclude fields from the subset specified in _source_includes query parameter.\n\nIf the _source parameter is false, this parameter is ignored.'
201
+ },
202
+ _source_includes: {
203
+ type: 'array',
204
+ items: {
205
+ type: 'string'
206
+ },
207
+ description: 'A comma-separated list of source fields to include in the response.\n\nIf this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the _source_excludes query parameter.\n\nIf the _source parameter is false, this parameter is ignored.'
208
+ },
209
+ stats: {
210
+ description: 'Specific tag of the request for logging and statistical purposes',
211
+ anyOf: [
212
+ {
213
+ items: {
214
+ type: 'string'
215
+ },
216
+ type: 'array'
217
+ },
218
+ {
219
+ type: 'string'
220
+ },
221
+ ]
222
+ },
223
+ terminate_after: {
224
+ description: 'The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. Elasticsearch collects documents before sorting.\nUse with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.',
225
+ type: 'number'
226
+ },
227
+ timeout: {
228
+ type: 'string',
229
+ description: 'Period each deletion request waits for active shards. Defaults to 1m (one minute).',
230
+ default: '1m'
231
+ },
232
+ version: {
233
+ description: 'Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.',
234
+ type: 'integer'
235
+ },
236
+ wait_for_active_shards: {
237
+ type: 'string',
238
+ description: 'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.',
239
+ default: '1'
240
+ }
241
+ },
242
+ errorMessage: {
243
+ type: 'ElasticsearchDelete request properties should be an object.'
244
+ }
245
+ };
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,8 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { Client } from '@elastic/elasticsearch';
16
- async function elasticsearchIndex({ request , connection }) {
16
+ import schema from './schema.js';
17
+ async function ElasticsearchIndex({ request , connection }) {
17
18
  const client = new Client(connection);
18
19
  const body = {
19
20
  ...request,
@@ -25,4 +26,9 @@ async function elasticsearchIndex({ request , connection }) {
25
26
  id: response._id
26
27
  };
27
28
  }
28
- export default elasticsearchIndex;
29
+ ElasticsearchIndex.schema = schema;
30
+ ElasticsearchIndex.meta = {
31
+ checkRead: false,
32
+ checkWrite: true
33
+ };
34
+ export default ElasticsearchIndex;
@@ -0,0 +1,114 @@
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 - ElasticsearchIndex',
18
+ type: 'object',
19
+ description: 'Adds a JSON document to the specified data stream or index and makes it searchable. If the target is an index and the document already exists, the request updates the document and increments its version.',
20
+ required: [
21
+ 'body'
22
+ ],
23
+ properties: {
24
+ id: {
25
+ anyOf: [
26
+ {
27
+ type: 'string'
28
+ },
29
+ {
30
+ type: 'number'
31
+ },
32
+ ],
33
+ description: 'Unique identifier for the document.'
34
+ },
35
+ index: {
36
+ type: 'string',
37
+ description: 'The name of the index.'
38
+ },
39
+ if_seq_no: {
40
+ type: 'integer',
41
+ description: 'Only perform the operation if the document has this sequence number. See Optimistic concurrency control.'
42
+ },
43
+ if_primary_term: {
44
+ type: 'integer',
45
+ description: 'Only perform the operation if the document has this primary term. See Optimistic concurrency control.'
46
+ },
47
+ op_type: {
48
+ type: 'string',
49
+ description: 'Set to create to only index the document if it does not already exist (put if absent). If a document with the specified _id already exists, the indexing operation will fail. Same as using the <index>/_create endpoint. Valid values: index, create. If document id is specified, it defaults to index. Otherwise, it defaults to create. If the request targets a data stream, an op_type of create is required. See Add documents to a data stream.',
50
+ enum: [
51
+ 'index',
52
+ 'create'
53
+ ],
54
+ default: 'create'
55
+ },
56
+ pipeline: {
57
+ type: 'string',
58
+ description: 'ID of the pipeline to use to preprocess incoming documents.'
59
+ },
60
+ refresh: {
61
+ type: 'string',
62
+ description: 'If true, Elasticsearch refreshes the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false do nothing with refreshes. Valid values: true, false, wait_for. Default: false.',
63
+ enum: [
64
+ 'true',
65
+ 'false',
66
+ 'wait_for'
67
+ ],
68
+ default: false
69
+ },
70
+ routing: {
71
+ description: 'Custom value used to route operations to a specific shard.',
72
+ type: 'string'
73
+ },
74
+ timeout: {
75
+ type: 'string',
76
+ description: 'Period the request waits for the following operations:\n\nAutomatic index creation\nDynamic mapping updates\nWaiting for active shards\nDefaults to 1m (one minute). This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.',
77
+ default: '1m'
78
+ },
79
+ version: {
80
+ description: 'Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.',
81
+ type: 'integer'
82
+ },
83
+ version_type: {
84
+ type: 'string',
85
+ description: 'Specific version type: external, external_gte.',
86
+ enum: [
87
+ 'internal',
88
+ 'external',
89
+ 'external_gte'
90
+ ]
91
+ },
92
+ wait_for_active_shard: {
93
+ type: 'string',
94
+ description: 'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.',
95
+ default: '1'
96
+ },
97
+ require_alias: {
98
+ type: 'boolean',
99
+ description: 'If true, the destination must be an index alias. Defaults to false.',
100
+ default: false
101
+ },
102
+ body: {
103
+ type: 'object',
104
+ description: 'Request body contains the JSON source for the document data.',
105
+ additionalProperties: true
106
+ }
107
+ },
108
+ errorMessage: {
109
+ type: 'ElasticsearchIndex request properties should be an object.',
110
+ required: {
111
+ body: 'ElasticsearchIndex request should have required property "body".'
112
+ }
113
+ }
114
+ };
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,8 +14,8 @@
14
14
  limitations under the License.
15
15
  */ import { Client } from '@elastic/elasticsearch';
16
16
  import { get } from '@lowdefy/helpers';
17
- import schema from './ElasticsearchSearch.json';
18
- async function elasticsearchSearch({ request , connection }) {
17
+ import schema from './schema.js';
18
+ async function ElasticsearchSearch({ request , connection }) {
19
19
  const client = new Client(connection);
20
20
  const { body: response } = await client.search({
21
21
  ...request,
@@ -39,16 +39,19 @@ async function elasticsearchSearch({ request , connection }) {
39
39
  response,
40
40
  hits,
41
41
  total: get(response, 'hits.total', {
42
- default: {
43
- }
42
+ default: {}
44
43
  }),
45
44
  maxScore: get(response, 'hits.max_score', {
46
45
  default: 0
47
46
  }),
48
47
  aggregations: get(response, 'aggregations', {
49
- default: {
50
- }
48
+ default: {}
51
49
  })
52
50
  };
53
51
  }
54
- export default elasticsearchSearch;
52
+ ElasticsearchSearch.schema = schema;
53
+ ElasticsearchSearch.meta = {
54
+ checkRead: true,
55
+ checkWrite: false
56
+ };
57
+ export default ElasticsearchSearch;