@opensearch-project/opensearch 1.0.0 → 2.0.0
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/.eslintignore +2 -0
- package/.eslintrc.json +26 -0
- package/.prettierrc.json +5 -0
- package/.whitesource +15 -0
- package/ADMINS.md +18 -11
- package/COMPATIBILITY.md +24 -0
- package/DEVELOPER_GUIDE.md +22 -5
- package/MAINTAINERS.md +23 -18
- package/README.md +102 -106
- package/RELEASING.md +3 -3
- package/SECURITY.md +1 -1
- package/api/api/bulk.js +53 -26
- package/api/api/cat.js +354 -264
- package/api/api/clear_scroll.js +17 -17
- package/api/api/cluster.js +366 -219
- package/api/api/count.js +55 -24
- package/api/api/create.js +50 -24
- package/api/api/dangling_indices.js +95 -51
- package/api/api/delete.js +49 -22
- package/api/api/delete_by_query.js +88 -25
- package/api/api/delete_by_query_rethrottle.js +33 -19
- package/api/api/delete_script.js +31 -17
- package/api/api/exists.js +55 -22
- package/api/api/exists_source.js +60 -27
- package/api/api/explain.js +60 -22
- package/api/api/features.js +56 -35
- package/api/api/field_caps.js +36 -18
- package/api/api/get.js +55 -22
- package/api/api/get_script.js +30 -17
- package/api/api/get_script_context.js +15 -15
- package/api/api/get_script_languages.js +15 -15
- package/api/api/get_source.js +55 -22
- package/api/api/index.js +60 -28
- package/api/api/indices.js +1068 -857
- package/api/api/info.js +15 -15
- package/api/api/ingest.js +132 -96
- package/api/api/mget.js +50 -26
- package/api/api/msearch.js +49 -26
- package/api/api/msearch_template.js +53 -26
- package/api/api/mtermvectors.js +48 -24
- package/api/api/nodes.js +281 -154
- package/api/api/ping.js +15 -15
- package/api/api/put_script.js +40 -25
- package/api/api/rank_eval.js +37 -20
- package/api/api/reindex.js +38 -17
- package/api/api/reindex_rethrottle.js +32 -19
- package/api/api/render_search_template.js +18 -18
- package/api/api/scripts_painless_execute.js +15 -15
- package/api/api/scroll.js +31 -17
- package/api/api/search.js +108 -24
- package/api/api/search_shards.js +36 -18
- package/api/api/search_template.js +64 -26
- package/api/api/shutdown.js +66 -54
- package/api/api/snapshot.js +347 -224
- package/api/api/tasks.js +65 -46
- package/api/api/terms_enum.js +17 -17
- package/api/api/termvectors.js +57 -26
- package/api/api/update.js +64 -24
- package/api/api/update_by_query.js +89 -23
- package/api/api/update_by_query_rethrottle.js +33 -19
- package/api/index.js +267 -179
- package/api/new.d.ts +2042 -529
- package/api/opensearch_dashboards.d.ts +275 -0
- package/api/requestParams.d.ts +301 -69
- package/api/types.d.ts +6204 -5719
- package/api/utils.js +22 -22
- package/codecov.yml +2 -2
- package/index.d.ts +4779 -934
- package/index.js +153 -140
- package/index.mjs +9 -9
- package/lib/Connection.d.ts +37 -26
- package/lib/Connection.js +163 -168
- package/lib/Helpers.d.ts +103 -63
- package/lib/Helpers.js +398 -371
- package/lib/Serializer.d.ts +2 -2
- package/lib/Serializer.js +39 -39
- package/lib/Transport.d.ts +30 -12
- package/lib/Transport.js +383 -324
- package/lib/errors.d.ts +25 -7
- package/lib/errors.js +75 -71
- package/lib/pool/BaseConnectionPool.js +100 -97
- package/lib/pool/CloudConnectionPool.js +16 -16
- package/lib/pool/ConnectionPool.js +105 -105
- package/lib/pool/index.d.ts +8 -6
- package/lib/pool/index.js +6 -6
- package/package.json +13 -8
package/lib/Helpers.d.ts
CHANGED
|
@@ -28,108 +28,148 @@
|
|
|
28
28
|
* under the License.
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
|
-
import { Readable as ReadableStream } from 'stream'
|
|
32
|
-
import { TransportRequestOptions, ApiError, ApiResponse, RequestBody, Context } from './Transport'
|
|
33
|
-
import { Search, Msearch, Bulk } from '../api/requestParams'
|
|
31
|
+
import { Readable as ReadableStream } from 'stream';
|
|
32
|
+
import { TransportRequestOptions, ApiError, ApiResponse, RequestBody, Context } from './Transport';
|
|
33
|
+
import { Search, Msearch, Bulk } from '../api/requestParams';
|
|
34
34
|
|
|
35
35
|
export default class Helpers {
|
|
36
|
-
search<TDocument = unknown, TRequestBody extends RequestBody = Record<string, any>>(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
search<TDocument = unknown, TRequestBody extends RequestBody = Record<string, any>>(
|
|
37
|
+
params: Search<TRequestBody>,
|
|
38
|
+
options?: TransportRequestOptions
|
|
39
|
+
): Promise<TDocument[]>;
|
|
40
|
+
scrollSearch<
|
|
41
|
+
TDocument = unknown,
|
|
42
|
+
TResponse = Record<string, any>,
|
|
43
|
+
TRequestBody extends RequestBody = Record<string, any>,
|
|
44
|
+
TContext = Context
|
|
45
|
+
>(
|
|
46
|
+
params: Search<TRequestBody>,
|
|
47
|
+
options?: TransportRequestOptions
|
|
48
|
+
): AsyncIterable<ScrollSearchResponse<TDocument, TResponse, TContext>>;
|
|
49
|
+
scrollDocuments<TDocument = unknown, TRequestBody extends RequestBody = Record<string, any>>(
|
|
50
|
+
params: Search<TRequestBody>,
|
|
51
|
+
options?: TransportRequestOptions
|
|
52
|
+
): AsyncIterable<TDocument>;
|
|
53
|
+
msearch(options?: MsearchHelperOptions, reqOptions?: TransportRequestOptions): MsearchHelper;
|
|
54
|
+
bulk<TDocument = unknown>(
|
|
55
|
+
options: BulkHelperOptions<TDocument>,
|
|
56
|
+
reqOptions?: TransportRequestOptions
|
|
57
|
+
): BulkHelper<BulkStats>;
|
|
41
58
|
}
|
|
42
59
|
|
|
43
|
-
export interface ScrollSearchResponse<
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
export interface ScrollSearchResponse<
|
|
61
|
+
TDocument = unknown,
|
|
62
|
+
TResponse = Record<string, any>,
|
|
63
|
+
TContext = Context
|
|
64
|
+
> extends ApiResponse<TResponse, TContext> {
|
|
65
|
+
clear: () => Promise<void>;
|
|
66
|
+
documents: TDocument[];
|
|
46
67
|
}
|
|
47
68
|
|
|
48
69
|
export interface BulkHelper<T> extends Promise<T> {
|
|
49
|
-
abort: () => BulkHelper<T
|
|
50
|
-
readonly stats: BulkStats
|
|
70
|
+
abort: () => BulkHelper<T>;
|
|
71
|
+
readonly stats: BulkStats;
|
|
51
72
|
}
|
|
52
73
|
|
|
53
74
|
export interface BulkStats {
|
|
54
|
-
total: number
|
|
55
|
-
failed: number
|
|
56
|
-
retry: number
|
|
57
|
-
successful: number
|
|
58
|
-
noop: number
|
|
59
|
-
time: number
|
|
60
|
-
bytes: number
|
|
61
|
-
aborted: boolean
|
|
75
|
+
total: number;
|
|
76
|
+
failed: number;
|
|
77
|
+
retry: number;
|
|
78
|
+
successful: number;
|
|
79
|
+
noop: number;
|
|
80
|
+
time: number;
|
|
81
|
+
bytes: number;
|
|
82
|
+
aborted: boolean;
|
|
62
83
|
}
|
|
63
84
|
|
|
64
85
|
interface IndexAction {
|
|
65
86
|
index: {
|
|
66
|
-
_index: string
|
|
67
|
-
[key: string]: any
|
|
68
|
-
}
|
|
87
|
+
_index: string;
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
};
|
|
69
90
|
}
|
|
70
91
|
|
|
71
92
|
interface CreateAction {
|
|
72
93
|
create: {
|
|
73
|
-
_index: string
|
|
74
|
-
[key: string]: any
|
|
75
|
-
}
|
|
94
|
+
_index: string;
|
|
95
|
+
[key: string]: any;
|
|
96
|
+
};
|
|
76
97
|
}
|
|
77
98
|
|
|
78
99
|
interface UpdateActionOperation {
|
|
79
100
|
update: {
|
|
80
|
-
_index: string
|
|
81
|
-
[key: string]: any
|
|
82
|
-
}
|
|
101
|
+
_index: string;
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
};
|
|
83
104
|
}
|
|
84
105
|
|
|
85
106
|
interface DeleteAction {
|
|
86
107
|
delete: {
|
|
87
|
-
_index: string
|
|
88
|
-
[key: string]: any
|
|
89
|
-
}
|
|
108
|
+
_index: string;
|
|
109
|
+
[key: string]: any;
|
|
110
|
+
};
|
|
90
111
|
}
|
|
91
112
|
|
|
92
|
-
type UpdateAction = [UpdateActionOperation, Record<string, any>]
|
|
93
|
-
type Action = IndexAction | CreateAction | UpdateAction | DeleteAction
|
|
94
|
-
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K
|
|
113
|
+
type UpdateAction = [UpdateActionOperation, Record<string, any>];
|
|
114
|
+
type Action = IndexAction | CreateAction | UpdateAction | DeleteAction;
|
|
115
|
+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
95
116
|
|
|
96
117
|
export interface BulkHelperOptions<TDocument = unknown> extends Omit<Bulk, 'body'> {
|
|
97
|
-
datasource: TDocument[] | Buffer | ReadableStream | AsyncIterator<TDocument
|
|
98
|
-
onDocument: (doc: TDocument) => Action
|
|
99
|
-
flushBytes?: number
|
|
100
|
-
flushInterval?: number
|
|
101
|
-
concurrency?: number
|
|
102
|
-
retries?: number
|
|
103
|
-
wait?: number
|
|
104
|
-
onDrop?: (doc: OnDropDocument<TDocument>) => void
|
|
105
|
-
refreshOnCompletion?: boolean | string
|
|
118
|
+
datasource: TDocument[] | Buffer | ReadableStream | AsyncIterator<TDocument>;
|
|
119
|
+
onDocument: (doc: TDocument) => Action;
|
|
120
|
+
flushBytes?: number;
|
|
121
|
+
flushInterval?: number;
|
|
122
|
+
concurrency?: number;
|
|
123
|
+
retries?: number;
|
|
124
|
+
wait?: number;
|
|
125
|
+
onDrop?: (doc: OnDropDocument<TDocument>) => void;
|
|
126
|
+
refreshOnCompletion?: boolean | string;
|
|
106
127
|
}
|
|
107
128
|
|
|
108
129
|
export interface OnDropDocument<TDocument = unknown> {
|
|
109
|
-
status: number
|
|
130
|
+
status: number;
|
|
110
131
|
error: {
|
|
111
|
-
type: string
|
|
112
|
-
reason: string
|
|
132
|
+
type: string;
|
|
133
|
+
reason: string;
|
|
113
134
|
caused_by: {
|
|
114
|
-
type: string
|
|
115
|
-
reason: string
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
135
|
+
type: string;
|
|
136
|
+
reason: string;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
operation: Action;
|
|
140
|
+
document: TDocument;
|
|
141
|
+
retried: boolean;
|
|
120
142
|
}
|
|
121
143
|
|
|
122
144
|
export interface MsearchHelperOptions extends Omit<Msearch, 'body'> {
|
|
123
|
-
operations?: number
|
|
124
|
-
flushInterval?: number
|
|
125
|
-
concurrency?: number
|
|
126
|
-
retries?: number
|
|
127
|
-
wait?: number
|
|
145
|
+
operations?: number;
|
|
146
|
+
flushInterval?: number;
|
|
147
|
+
concurrency?: number;
|
|
148
|
+
retries?: number;
|
|
149
|
+
wait?: number;
|
|
128
150
|
}
|
|
129
151
|
|
|
130
|
-
declare type callbackFn<Response, Context> = (
|
|
152
|
+
declare type callbackFn<Response, Context> = (
|
|
153
|
+
err: ApiError,
|
|
154
|
+
result: ApiResponse<Response, Context>
|
|
155
|
+
) => void;
|
|
131
156
|
export interface MsearchHelper extends Promise<void> {
|
|
132
|
-
stop(error?: Error): void
|
|
133
|
-
search<
|
|
134
|
-
|
|
157
|
+
stop(error?: Error): void;
|
|
158
|
+
search<
|
|
159
|
+
TResponse = Record<string, any>,
|
|
160
|
+
TRequestBody extends RequestBody = Record<string, any>,
|
|
161
|
+
TContext = Context
|
|
162
|
+
>(
|
|
163
|
+
header: Omit<Search, 'body'>,
|
|
164
|
+
body: TRequestBody
|
|
165
|
+
): Promise<ApiResponse<TResponse, TContext>>;
|
|
166
|
+
search<
|
|
167
|
+
TResponse = Record<string, any>,
|
|
168
|
+
TRequestBody extends RequestBody = Record<string, any>,
|
|
169
|
+
TContext = Context
|
|
170
|
+
>(
|
|
171
|
+
header: Omit<Search, 'body'>,
|
|
172
|
+
body: TRequestBody,
|
|
173
|
+
callback: callbackFn<TResponse, TContext>
|
|
174
|
+
): void;
|
|
135
175
|
}
|