couchbase 4.2.10 → 4.2.11
Sign up to get free protection for your applications and to get access to all the features.
- package/deps/couchbase-cxx-client/CMakeLists.txt +1 -0
- package/deps/couchbase-cxx-client/cmake/ThirdPartyDependencies.cmake +2 -0
- package/deps/couchbase-cxx-client/core/bucket.cxx +25 -10
- package/deps/couchbase-cxx-client/core/bucket.hxx +1 -0
- package/deps/couchbase-cxx-client/core/cluster.cxx +29 -3
- package/deps/couchbase-cxx-client/core/impl/collection.cxx +2 -2
- package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
- package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +7 -1
- package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +10 -0
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +35 -1
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +2 -0
- package/deps/couchbase-cxx-client/core/management/design_document.hxx +1 -1
- package/deps/couchbase-cxx-client/core/meta/features.hxx +16 -1
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/document_query.cxx +2 -2
- package/deps/couchbase-cxx-client/core/operations/document_search.cxx +10 -10
- package/deps/couchbase-cxx-client/core/operations/document_view.cxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
- package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +24 -13
- package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -1
- package/deps/couchbase-cxx-client/core/origin.cxx +14 -0
- package/deps/couchbase-cxx-client/core/origin.hxx +6 -0
- package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -0
- package/deps/couchbase-cxx-client/core/protocol/status.hxx +1 -0
- package/deps/couchbase-cxx-client/core/range_scan_load_balancer.cxx +141 -0
- package/deps/couchbase-cxx-client/core/range_scan_load_balancer.hxx +64 -0
- package/deps/couchbase-cxx-client/core/range_scan_orchestrator.cxx +224 -336
- package/deps/couchbase-cxx-client/core/range_scan_orchestrator.hxx +5 -6
- package/deps/couchbase-cxx-client/core/range_scan_orchestrator_options.hxx +6 -4
- package/deps/couchbase-cxx-client/core/scan_result.hxx +1 -11
- package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +70 -1
- package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +30 -2
- package/deps/couchbase-cxx-client/core/topology/configuration.hxx +1 -34
- package/deps/couchbase-cxx-client/core/topology/configuration_fmt.hxx +2 -2
- package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +43 -20
- package/deps/couchbase-cxx-client/core/transactions/internal/exceptions_internal.hxx +5 -0
- package/deps/couchbase-cxx-client/couchbase/bucket.hxx +2 -2
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/collection.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +80 -11
- package/deps/couchbase-cxx-client/couchbase/error_context.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/key_value_status_code.hxx +3 -1
- package/deps/couchbase-cxx-client/couchbase/get_links_analytics_options.hxx +2 -2
- package/deps/couchbase-cxx-client/couchbase/key_value_status_code.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +6 -8
- package/deps/couchbase-cxx-client/couchbase/scope.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/search_options.hxx +2 -2
- package/deps/couchbase-cxx-client/couchbase/search_result.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase-sdk-cxx-black-duck-manifest.yaml +1 -0
- package/dist/binding.d.ts +24 -2
- package/dist/bindingutilities.d.ts +11 -3
- package/dist/bindingutilities.js +33 -7
- package/dist/couchbase.d.ts +1 -0
- package/dist/couchbase.js +1 -0
- package/dist/queryindexmanager.d.ts +4 -4
- package/dist/queryindexmanager.js +7 -7
- package/dist/scope.d.ts +21 -0
- package/dist/scope.js +34 -0
- package/dist/scopesearchindexmanager.d.ts +116 -0
- package/dist/scopesearchindexmanager.js +406 -0
- package/dist/sdspecs.js +10 -9
- package/dist/sdutils.d.ts +1 -0
- package/dist/sdutils.js +4 -0
- package/dist/searchexecutor.d.ts +3 -1
- package/dist/searchexecutor.js +9 -2
- package/dist/searchindexmanager.d.ts +58 -3
- package/dist/searchindexmanager.js +188 -104
- package/dist/viewexecutor.js +13 -9
- package/dist/viewindexmanager.d.ts +70 -7
- package/dist/viewindexmanager.js +236 -103
- package/dist/viewtypes.d.ts +26 -0
- package/dist/viewtypes.js +17 -1
- package/package.json +7 -7
- package/src/constants.cpp +1 -0
- package/src/jstocbpp_autogen.hpp +89 -7
- package/deps/couchbase-cxx-client/core/scan_options.hxx +0 -44
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Cluster } from './cluster';
|
2
2
|
import { NodeCallback } from './utilities';
|
3
|
+
import { CppManagementSearchIndex } from './binding';
|
3
4
|
/**
|
4
5
|
* Provides information about a search index. This class is currently
|
5
6
|
* incomplete and must be casted from `any` in TypeScript.
|
@@ -57,15 +58,62 @@ export interface ISearchIndex {
|
|
57
58
|
*
|
58
59
|
* @category Management
|
59
60
|
*/
|
60
|
-
export declare class SearchIndex {
|
61
|
+
export declare class SearchIndex implements ISearchIndex {
|
62
|
+
/**
|
63
|
+
* The UUID of the search index. Used for updates to ensure consistency.
|
64
|
+
*/
|
65
|
+
uuid?: string;
|
61
66
|
/**
|
62
67
|
* The name of the search index.
|
63
68
|
*/
|
64
69
|
name: string;
|
70
|
+
/**
|
71
|
+
* Name of the source of the data (ie: the bucket name).
|
72
|
+
*/
|
73
|
+
sourceName: string;
|
74
|
+
/**
|
75
|
+
* The type of index to use (fulltext-index or fulltext-alias).
|
76
|
+
*/
|
77
|
+
type: string;
|
78
|
+
/**
|
79
|
+
* Parameters to specify such as the store type and mappins.
|
80
|
+
*/
|
81
|
+
params: {
|
82
|
+
[key: string]: any;
|
83
|
+
};
|
84
|
+
/**
|
85
|
+
* The UUID of the data source.
|
86
|
+
*/
|
87
|
+
sourceUuid: string;
|
88
|
+
/**
|
89
|
+
* Extra parameters for the source. These are usually things like advanced
|
90
|
+
* connection options and tuning parameters.
|
91
|
+
*/
|
92
|
+
sourceParams: {
|
93
|
+
[key: string]: any;
|
94
|
+
};
|
95
|
+
/**
|
96
|
+
* The type of the source (couchbase or nil).
|
97
|
+
*/
|
98
|
+
sourceType: string;
|
99
|
+
/**
|
100
|
+
* Plan properties such as the number of replicas and number of partitions.
|
101
|
+
*/
|
102
|
+
planParams: {
|
103
|
+
[key: string]: any;
|
104
|
+
};
|
65
105
|
/**
|
66
106
|
* @internal
|
67
107
|
*/
|
68
108
|
constructor(data: SearchIndex);
|
109
|
+
/**
|
110
|
+
* @internal
|
111
|
+
*/
|
112
|
+
static _toCppData(data: ISearchIndex): any;
|
113
|
+
/**
|
114
|
+
* @internal
|
115
|
+
*/
|
116
|
+
static _fromCppData(data: CppManagementSearchIndex): SearchIndex;
|
69
117
|
}
|
70
118
|
/**
|
71
119
|
* @category Management
|
@@ -187,7 +235,6 @@ export declare class SearchIndexManager {
|
|
187
235
|
* @internal
|
188
236
|
*/
|
189
237
|
constructor(cluster: Cluster);
|
190
|
-
private get _http();
|
191
238
|
/**
|
192
239
|
* Returns an index by it's name.
|
193
240
|
*
|
@@ -267,6 +314,14 @@ export declare class SearchIndexManager {
|
|
267
314
|
* @param callback A node-style callback to be invoked after execution.
|
268
315
|
*/
|
269
316
|
freezePlan(indexName: string, options?: FreezeSearchPlanOptions, callback?: NodeCallback<void>): Promise<void>;
|
317
|
+
/**
|
318
|
+
* Unfreezes the indexing plan for execution of queries.
|
319
|
+
*
|
320
|
+
* @param indexName The name of the index to freeze the plan of.
|
321
|
+
* @param options Optional parameters for this operation.
|
322
|
+
* @param callback A node-style callback to be invoked after execution.
|
323
|
+
*/
|
324
|
+
unfreezePlan(indexName: string, options?: UnfreezeSearchPlanOptions, callback?: NodeCallback<void>): Promise<void>;
|
270
325
|
/**
|
271
326
|
* Performs analysis of a specific document by an index.
|
272
327
|
*
|
@@ -275,5 +330,5 @@ export declare class SearchIndexManager {
|
|
275
330
|
* @param options Optional parameters for this operation.
|
276
331
|
* @param callback A node-style callback to be invoked after execution.
|
277
332
|
*/
|
278
|
-
analyzeDocument(indexName: string, document: any, options?: AnalyzeSearchDocumentOptions, callback?: NodeCallback<
|
333
|
+
analyzeDocument(indexName: string, document: any, options?: AnalyzeSearchDocumentOptions, callback?: NodeCallback<any>): Promise<any>;
|
279
334
|
}
|
@@ -1,9 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.SearchIndexManager = exports.SearchIndex = void 0;
|
4
|
-
const errors_1 = require("./errors");
|
5
|
-
const httpexecutor_1 = require("./httpexecutor");
|
6
4
|
const utilities_1 = require("./utilities");
|
5
|
+
const bindingutilities_1 = require("./bindingutilities");
|
7
6
|
/**
|
8
7
|
* This class is currently incomplete and must be casted to `any` in
|
9
8
|
* TypeScript to be used.
|
@@ -15,7 +14,57 @@ class SearchIndex {
|
|
15
14
|
* @internal
|
16
15
|
*/
|
17
16
|
constructor(data) {
|
17
|
+
this.uuid = data.uuid;
|
18
18
|
this.name = data.name;
|
19
|
+
this.sourceName = data.sourceName;
|
20
|
+
this.type = data.type;
|
21
|
+
this.params = data.params;
|
22
|
+
this.sourceUuid = data.sourceUuid;
|
23
|
+
this.sourceParams = data.sourceParams;
|
24
|
+
this.sourceType = data.sourceType;
|
25
|
+
this.planParams = data.planParams;
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* @internal
|
29
|
+
*/
|
30
|
+
static _toCppData(data) {
|
31
|
+
return {
|
32
|
+
uuid: data.uuid,
|
33
|
+
name: data.name,
|
34
|
+
type: data.type,
|
35
|
+
params_json: JSON.stringify(data.params),
|
36
|
+
source_uuid: data.sourceUuid,
|
37
|
+
source_name: data.sourceName,
|
38
|
+
source_type: data.sourceType,
|
39
|
+
source_params_json: JSON.stringify(data.sourceParams),
|
40
|
+
plan_params_json: JSON.stringify(data.planParams),
|
41
|
+
};
|
42
|
+
}
|
43
|
+
/**
|
44
|
+
* @internal
|
45
|
+
*/
|
46
|
+
static _fromCppData(data) {
|
47
|
+
const idx = new SearchIndex({
|
48
|
+
uuid: data.uuid,
|
49
|
+
name: data.name,
|
50
|
+
type: data.type,
|
51
|
+
params: {},
|
52
|
+
sourceUuid: data.source_uuid,
|
53
|
+
sourceName: data.source_name,
|
54
|
+
sourceType: data.source_type,
|
55
|
+
sourceParams: {},
|
56
|
+
planParams: {},
|
57
|
+
});
|
58
|
+
if (data.params_json) {
|
59
|
+
idx.params = JSON.parse(data.params_json);
|
60
|
+
}
|
61
|
+
if (data.source_params_json) {
|
62
|
+
idx.sourceParams = JSON.parse(data.source_params_json);
|
63
|
+
}
|
64
|
+
if (data.plan_params_json) {
|
65
|
+
idx.planParams = JSON.parse(data.plan_params_json);
|
66
|
+
}
|
67
|
+
return idx;
|
19
68
|
}
|
20
69
|
}
|
21
70
|
exports.SearchIndex = SearchIndex;
|
@@ -32,9 +81,6 @@ class SearchIndexManager {
|
|
32
81
|
constructor(cluster) {
|
33
82
|
this._cluster = cluster;
|
34
83
|
}
|
35
|
-
get _http() {
|
36
|
-
return new httpexecutor_1.HttpExecutor(this._cluster.conn);
|
37
|
-
}
|
38
84
|
/**
|
39
85
|
* Returns an index by it's name.
|
40
86
|
*
|
@@ -51,18 +97,18 @@ class SearchIndexManager {
|
|
51
97
|
options = {};
|
52
98
|
}
|
53
99
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
54
|
-
return utilities_1.PromiseHelper.
|
55
|
-
|
56
|
-
|
57
|
-
method: httpexecutor_1.HttpMethod.Get,
|
58
|
-
path: `/api/index/${indexName}`,
|
100
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
101
|
+
this._cluster.conn.managementSearchIndexGet({
|
102
|
+
index_name: indexName,
|
59
103
|
timeout: timeout,
|
104
|
+
}, (cppErr, resp) => {
|
105
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
106
|
+
if (err) {
|
107
|
+
return wrapCallback(err, null);
|
108
|
+
}
|
109
|
+
const index = SearchIndex._fromCppData(resp.index);
|
110
|
+
wrapCallback(null, index);
|
60
111
|
});
|
61
|
-
if (res.statusCode !== 200) {
|
62
|
-
throw new errors_1.IndexNotFoundError();
|
63
|
-
}
|
64
|
-
const idxData = JSON.parse(res.body.toString());
|
65
|
-
return idxData.indexDef;
|
66
112
|
}, callback);
|
67
113
|
}
|
68
114
|
/**
|
@@ -80,18 +126,17 @@ class SearchIndexManager {
|
|
80
126
|
options = {};
|
81
127
|
}
|
82
128
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
83
|
-
return utilities_1.PromiseHelper.
|
84
|
-
|
85
|
-
type: httpexecutor_1.HttpServiceType.Search,
|
86
|
-
method: httpexecutor_1.HttpMethod.Get,
|
87
|
-
path: `/api/index`,
|
129
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
130
|
+
this._cluster.conn.managementSearchIndexGetAll({
|
88
131
|
timeout: timeout,
|
132
|
+
}, (cppErr, resp) => {
|
133
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
134
|
+
if (err) {
|
135
|
+
return wrapCallback(err, null);
|
136
|
+
}
|
137
|
+
const indexes = resp.indexes.map((indexData) => SearchIndex._fromCppData(indexData));
|
138
|
+
wrapCallback(null, indexes);
|
89
139
|
});
|
90
|
-
if (res.statusCode !== 200) {
|
91
|
-
throw new Error('failed to fetch search indices');
|
92
|
-
}
|
93
|
-
const idxsData = JSON.parse(res.body.toString());
|
94
|
-
return Object.values(idxsData.indexDefs.indexDefs);
|
95
140
|
}, callback);
|
96
141
|
}
|
97
142
|
/**
|
@@ -109,20 +154,18 @@ class SearchIndexManager {
|
|
109
154
|
if (!options) {
|
110
155
|
options = {};
|
111
156
|
}
|
112
|
-
const indexName = indexDefinition.name;
|
113
157
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
114
|
-
return utilities_1.PromiseHelper.
|
115
|
-
|
116
|
-
|
117
|
-
method: httpexecutor_1.HttpMethod.Put,
|
118
|
-
path: `/api/index/${indexName}`,
|
119
|
-
contentType: 'application/json',
|
120
|
-
body: JSON.stringify(indexDefinition),
|
158
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
159
|
+
this._cluster.conn.managementSearchIndexUpsert({
|
160
|
+
index: SearchIndex._toCppData(indexDefinition),
|
121
161
|
timeout: timeout,
|
162
|
+
}, (cppErr) => {
|
163
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
164
|
+
if (err) {
|
165
|
+
return wrapCallback(err, null);
|
166
|
+
}
|
167
|
+
wrapCallback(err);
|
122
168
|
});
|
123
|
-
if (res.statusCode !== 200) {
|
124
|
-
throw new Error('failed to create index');
|
125
|
-
}
|
126
169
|
}, callback);
|
127
170
|
}
|
128
171
|
/**
|
@@ -141,17 +184,17 @@ class SearchIndexManager {
|
|
141
184
|
options = {};
|
142
185
|
}
|
143
186
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
144
|
-
return utilities_1.PromiseHelper.
|
145
|
-
|
146
|
-
|
147
|
-
method: httpexecutor_1.HttpMethod.Delete,
|
148
|
-
path: `/api/index/${indexName}`,
|
187
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
188
|
+
this._cluster.conn.managementSearchIndexDrop({
|
189
|
+
index_name: indexName,
|
149
190
|
timeout: timeout,
|
191
|
+
}, (cppErr) => {
|
192
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
193
|
+
if (err) {
|
194
|
+
return wrapCallback(err, null);
|
195
|
+
}
|
196
|
+
wrapCallback(err);
|
150
197
|
});
|
151
|
-
if (res.statusCode !== 200) {
|
152
|
-
throw new Error('failed to delete search index');
|
153
|
-
}
|
154
|
-
return JSON.parse(res.body.toString());
|
155
198
|
}, callback);
|
156
199
|
}
|
157
200
|
/**
|
@@ -170,17 +213,17 @@ class SearchIndexManager {
|
|
170
213
|
options = {};
|
171
214
|
}
|
172
215
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
173
|
-
return utilities_1.PromiseHelper.
|
174
|
-
|
175
|
-
|
176
|
-
method: httpexecutor_1.HttpMethod.Get,
|
177
|
-
path: `/api/index/${indexName}/count`,
|
216
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
217
|
+
this._cluster.conn.managementSearchIndexGetDocumentsCount({
|
218
|
+
index_name: indexName,
|
178
219
|
timeout: timeout,
|
220
|
+
}, (cppErr, resp) => {
|
221
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
222
|
+
if (err) {
|
223
|
+
return wrapCallback(err, null);
|
224
|
+
}
|
225
|
+
wrapCallback(null, resp.count);
|
179
226
|
});
|
180
|
-
if (res.statusCode !== 200) {
|
181
|
-
throw new Error('failed to get search indexed documents count');
|
182
|
-
}
|
183
|
-
return JSON.parse(res.body.toString()).count;
|
184
227
|
}, callback);
|
185
228
|
}
|
186
229
|
/**
|
@@ -199,16 +242,18 @@ class SearchIndexManager {
|
|
199
242
|
options = {};
|
200
243
|
}
|
201
244
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
202
|
-
return utilities_1.PromiseHelper.
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
path: `/api/index/${indexName}/ingestControl/pause`,
|
245
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
246
|
+
this._cluster.conn.managementSearchIndexControlIngest({
|
247
|
+
index_name: indexName,
|
248
|
+
pause: true,
|
207
249
|
timeout: timeout,
|
250
|
+
}, (cppErr) => {
|
251
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
252
|
+
if (err) {
|
253
|
+
return wrapCallback(err, null);
|
254
|
+
}
|
255
|
+
wrapCallback(err);
|
208
256
|
});
|
209
|
-
if (res.statusCode !== 200) {
|
210
|
-
throw new Error('failed to pause search index ingestion');
|
211
|
-
}
|
212
257
|
}, callback);
|
213
258
|
}
|
214
259
|
/**
|
@@ -227,16 +272,18 @@ class SearchIndexManager {
|
|
227
272
|
options = {};
|
228
273
|
}
|
229
274
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
230
|
-
return utilities_1.PromiseHelper.
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
path: `/api/index/${indexName}/ingestControl/resume`,
|
275
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
276
|
+
this._cluster.conn.managementSearchIndexControlIngest({
|
277
|
+
index_name: indexName,
|
278
|
+
pause: false,
|
235
279
|
timeout: timeout,
|
280
|
+
}, (cppErr) => {
|
281
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
282
|
+
if (err) {
|
283
|
+
return wrapCallback(err, null);
|
284
|
+
}
|
285
|
+
wrapCallback(err);
|
236
286
|
});
|
237
|
-
if (res.statusCode !== 200) {
|
238
|
-
throw new Error('failed to resume search index ingestion');
|
239
|
-
}
|
240
287
|
}, callback);
|
241
288
|
}
|
242
289
|
/**
|
@@ -255,16 +302,18 @@ class SearchIndexManager {
|
|
255
302
|
options = {};
|
256
303
|
}
|
257
304
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
258
|
-
return utilities_1.PromiseHelper.
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
path: `/api/index/${indexName}/queryControl/allow`,
|
305
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
306
|
+
this._cluster.conn.managementSearchIndexControlQuery({
|
307
|
+
index_name: indexName,
|
308
|
+
allow: true,
|
263
309
|
timeout: timeout,
|
310
|
+
}, (cppErr) => {
|
311
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
312
|
+
if (err) {
|
313
|
+
return wrapCallback(err, null);
|
314
|
+
}
|
315
|
+
wrapCallback(err);
|
264
316
|
});
|
265
|
-
if (res.statusCode !== 200) {
|
266
|
-
throw new Error('failed to allow search index quering');
|
267
|
-
}
|
268
317
|
}, callback);
|
269
318
|
}
|
270
319
|
/**
|
@@ -283,16 +332,18 @@ class SearchIndexManager {
|
|
283
332
|
options = {};
|
284
333
|
}
|
285
334
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
286
|
-
return utilities_1.PromiseHelper.
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
path: `/api/index/${indexName}/queryControl/disallow`,
|
335
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
336
|
+
this._cluster.conn.managementSearchIndexControlQuery({
|
337
|
+
index_name: indexName,
|
338
|
+
allow: false,
|
291
339
|
timeout: timeout,
|
340
|
+
}, (cppErr) => {
|
341
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
342
|
+
if (err) {
|
343
|
+
return wrapCallback(err, null);
|
344
|
+
}
|
345
|
+
wrapCallback(err);
|
292
346
|
});
|
293
|
-
if (res.statusCode !== 200) {
|
294
|
-
throw new Error('failed to disallow search index quering');
|
295
|
-
}
|
296
347
|
}, callback);
|
297
348
|
}
|
298
349
|
/**
|
@@ -311,16 +362,48 @@ class SearchIndexManager {
|
|
311
362
|
options = {};
|
312
363
|
}
|
313
364
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
314
|
-
return utilities_1.PromiseHelper.
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
365
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
366
|
+
this._cluster.conn.managementSearchIndexControlPlanFreeze({
|
367
|
+
index_name: indexName,
|
368
|
+
freeze: true,
|
369
|
+
timeout: timeout,
|
370
|
+
}, (cppErr) => {
|
371
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
372
|
+
if (err) {
|
373
|
+
return wrapCallback(err, null);
|
374
|
+
}
|
375
|
+
wrapCallback(err);
|
376
|
+
});
|
377
|
+
}, callback);
|
378
|
+
}
|
379
|
+
/**
|
380
|
+
* Unfreezes the indexing plan for execution of queries.
|
381
|
+
*
|
382
|
+
* @param indexName The name of the index to freeze the plan of.
|
383
|
+
* @param options Optional parameters for this operation.
|
384
|
+
* @param callback A node-style callback to be invoked after execution.
|
385
|
+
*/
|
386
|
+
async unfreezePlan(indexName, options, callback) {
|
387
|
+
if (options instanceof Function) {
|
388
|
+
callback = arguments[1];
|
389
|
+
options = undefined;
|
390
|
+
}
|
391
|
+
if (!options) {
|
392
|
+
options = {};
|
393
|
+
}
|
394
|
+
const timeout = options.timeout || this._cluster.managementTimeout;
|
395
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
396
|
+
this._cluster.conn.managementSearchIndexControlPlanFreeze({
|
397
|
+
index_name: indexName,
|
398
|
+
freeze: false,
|
319
399
|
timeout: timeout,
|
400
|
+
}, (cppErr) => {
|
401
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
402
|
+
if (err) {
|
403
|
+
return wrapCallback(err, null);
|
404
|
+
}
|
405
|
+
wrapCallback(err);
|
320
406
|
});
|
321
|
-
if (res.statusCode !== 200) {
|
322
|
-
throw new Error('failed to freeze search index plan');
|
323
|
-
}
|
324
407
|
}, callback);
|
325
408
|
}
|
326
409
|
/**
|
@@ -340,18 +423,19 @@ class SearchIndexManager {
|
|
340
423
|
options = {};
|
341
424
|
}
|
342
425
|
const timeout = options.timeout || this._cluster.managementTimeout;
|
343
|
-
return utilities_1.PromiseHelper.
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
path: `/api/index/${indexName}/analyzeDoc`,
|
348
|
-
body: JSON.stringify(document),
|
426
|
+
return utilities_1.PromiseHelper.wrap((wrapCallback) => {
|
427
|
+
this._cluster.conn.managementSearchIndexAnalyzeDocument({
|
428
|
+
index_name: indexName,
|
429
|
+
encoded_document: JSON.stringify(document),
|
349
430
|
timeout: timeout,
|
431
|
+
}, (cppErr, resp) => {
|
432
|
+
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
433
|
+
if (err) {
|
434
|
+
return wrapCallback(err, null);
|
435
|
+
}
|
436
|
+
const result = JSON.parse(resp.analysis);
|
437
|
+
wrapCallback(result, null);
|
350
438
|
});
|
351
|
-
if (res.statusCode !== 200) {
|
352
|
-
throw new Error('failed to perform search index document analysis');
|
353
|
-
}
|
354
|
-
return JSON.parse(res.body.toString()).analyze;
|
355
439
|
}, callback);
|
356
440
|
}
|
357
441
|
}
|
package/dist/viewexecutor.js
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.ViewExecutor = void 0;
|
7
4
|
/* eslint jsdoc/require-jsdoc: off */
|
8
|
-
const binding_1 = __importDefault(require("./binding"));
|
9
5
|
const bindingutilities_1 = require("./bindingutilities");
|
10
6
|
const streamablepromises_1 = require("./streamablepromises");
|
11
7
|
const viewtypes_1 = require("./viewtypes");
|
@@ -29,6 +25,7 @@ class ViewExecutor {
|
|
29
25
|
* @internal
|
30
26
|
*/
|
31
27
|
query(designDoc, viewName, options) {
|
28
|
+
var _a;
|
32
29
|
const emitter = new streamablepromises_1.StreamableRowPromise((rows, meta) => {
|
33
30
|
return new viewtypes_1.ViewResult({
|
34
31
|
rows: rows,
|
@@ -36,12 +33,18 @@ class ViewExecutor {
|
|
36
33
|
});
|
37
34
|
});
|
38
35
|
const timeout = options.timeout || this._cluster.viewTimeout;
|
36
|
+
const raw = options.raw || {};
|
37
|
+
const ns = (_a = options.namespace) !== null && _a !== void 0 ? _a : viewtypes_1.DesignDocumentNamespace.Production;
|
38
|
+
let fullSet = options.full_set;
|
39
|
+
if (typeof options.fullSet !== 'undefined') {
|
40
|
+
fullSet = options.fullSet;
|
41
|
+
}
|
39
42
|
this._cluster.conn.documentView({
|
40
43
|
timeout: timeout,
|
41
44
|
bucket_name: this._bucket.name,
|
42
45
|
document_name: designDoc,
|
43
46
|
view_name: viewName,
|
44
|
-
ns:
|
47
|
+
ns: (0, bindingutilities_1.designDocumentNamespaceToCpp)(ns),
|
45
48
|
limit: options.limit,
|
46
49
|
skip: options.skip,
|
47
50
|
consistency: (0, bindingutilities_1.viewScanConsistencyToCpp)(options.scanConsistency),
|
@@ -55,10 +58,10 @@ class ViewExecutor {
|
|
55
58
|
: undefined,
|
56
59
|
inclusive_end: options.range ? options.range.inclusiveEnd : undefined,
|
57
60
|
start_key_doc_id: options.idRange && options.idRange.start
|
58
|
-
?
|
61
|
+
? options.idRange.start
|
59
62
|
: undefined,
|
60
63
|
end_key_doc_id: options.idRange && options.idRange.end
|
61
|
-
?
|
64
|
+
? options.idRange.end
|
62
65
|
: undefined,
|
63
66
|
reduce: options.reduce,
|
64
67
|
group: options.group,
|
@@ -66,7 +69,8 @@ class ViewExecutor {
|
|
66
69
|
order: (0, bindingutilities_1.viewOrderingToCpp)(options.order),
|
67
70
|
debug: false,
|
68
71
|
query_string: [],
|
69
|
-
raw:
|
72
|
+
raw: raw,
|
73
|
+
full_set: fullSet,
|
70
74
|
}, (cppErr, resp) => {
|
71
75
|
const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
|
72
76
|
if (err) {
|
@@ -78,7 +82,7 @@ class ViewExecutor {
|
|
78
82
|
emitter.emit('row', new viewtypes_1.ViewRow({
|
79
83
|
value: JSON.parse(row.value),
|
80
84
|
id: row.id,
|
81
|
-
key: row.key,
|
85
|
+
key: JSON.parse(row.key),
|
82
86
|
}));
|
83
87
|
});
|
84
88
|
{
|