couchbase 4.2.9 → 4.2.11-rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. package/deps/couchbase-cxx-client/CMakeLists.txt +4 -0
  2. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +7 -3
  3. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +1 -0
  4. package/deps/couchbase-cxx-client/core/bucket.cxx +67 -2
  5. package/deps/couchbase-cxx-client/core/bucket.hxx +2 -1
  6. package/deps/couchbase-cxx-client/core/cluster.cxx +65 -1
  7. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +24 -0
  8. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +73 -0
  9. package/deps/couchbase-cxx-client/core/impl/collection.cxx +2 -2
  10. package/deps/couchbase-cxx-client/core/impl/diagnostics.cxx +294 -0
  11. package/deps/couchbase-cxx-client/core/impl/diagnostics.hxx +39 -0
  12. package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
  13. package/deps/couchbase-cxx-client/core/impl/scope.cxx +19 -4
  14. package/deps/couchbase-cxx-client/core/impl/search.cxx +75 -2
  15. package/deps/couchbase-cxx-client/core/impl/search.hxx +8 -0
  16. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +261 -18
  17. package/deps/couchbase-cxx-client/core/impl/search_request.cxx +139 -0
  18. package/deps/couchbase-cxx-client/core/impl/vector_query.cxx +42 -0
  19. package/deps/couchbase-cxx-client/core/impl/vector_search.cxx +40 -0
  20. package/deps/couchbase-cxx-client/core/io/http_session.hxx +6 -3
  21. package/deps/couchbase-cxx-client/core/io/http_session_manager.hxx +7 -1
  22. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +10 -0
  23. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +48 -33
  24. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +2 -0
  25. package/deps/couchbase-cxx-client/core/logger/logger.cxx +1 -1
  26. package/deps/couchbase-cxx-client/core/management/design_document.hxx +1 -1
  27. package/deps/couchbase-cxx-client/core/meta/features.hxx +26 -1
  28. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_all_replicas.hxx +1 -1
  29. package/deps/couchbase-cxx-client/core/operations/document_lookup_in_any_replica.hxx +1 -1
  30. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +8 -3
  31. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +37 -1
  32. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +11 -0
  33. package/deps/couchbase-cxx-client/core/operations/document_view.cxx +3 -0
  34. package/deps/couchbase-cxx-client/core/operations/document_view.hxx +1 -0
  35. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +7 -6
  36. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +1 -1
  37. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +7 -8
  38. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +1 -1
  39. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +3 -0
  40. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.cxx +24 -13
  41. package/deps/couchbase-cxx-client/core/operations/management/query_index_create.hxx +1 -1
  42. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +17 -1
  43. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +3 -0
  44. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +21 -1
  45. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +3 -0
  46. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +21 -1
  47. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +3 -0
  48. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +21 -1
  49. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +3 -0
  50. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +17 -1
  51. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +3 -0
  52. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +17 -1
  53. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  54. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +39 -22
  55. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +3 -0
  56. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +18 -1
  57. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +3 -0
  58. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +17 -1
  59. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +3 -0
  60. package/deps/couchbase-cxx-client/core/origin.cxx +14 -0
  61. package/deps/couchbase-cxx-client/core/origin.hxx +6 -0
  62. package/deps/couchbase-cxx-client/core/protocol/status.cxx +2 -0
  63. package/deps/couchbase-cxx-client/core/protocol/status.hxx +1 -0
  64. package/deps/couchbase-cxx-client/core/topology/capabilities.hxx +70 -1
  65. package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +30 -2
  66. package/deps/couchbase-cxx-client/core/topology/collections_manifest.hxx +1 -1
  67. package/deps/couchbase-cxx-client/core/topology/collections_manifest_json.hxx +1 -1
  68. package/deps/couchbase-cxx-client/core/topology/configuration.hxx +1 -34
  69. package/deps/couchbase-cxx-client/core/topology/configuration_fmt.hxx +2 -2
  70. package/deps/couchbase-cxx-client/core/topology/configuration_json.hxx +43 -20
  71. package/deps/couchbase-cxx-client/core/transactions/internal/exceptions_internal.hxx +5 -0
  72. package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +4 -0
  73. package/deps/couchbase-cxx-client/core/vector_query_combination.hxx +23 -0
  74. package/deps/couchbase-cxx-client/couchbase/bucket.hxx +29 -0
  75. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +110 -0
  76. package/deps/couchbase-cxx-client/couchbase/codec/json_transcoder.hxx +1 -1
  77. package/deps/couchbase-cxx-client/couchbase/codec/raw_binary_transcoder.hxx +2 -1
  78. package/deps/couchbase-cxx-client/couchbase/codec/raw_json_transcoder.hxx +78 -0
  79. package/deps/couchbase-cxx-client/couchbase/codec/raw_string_transcoder.hxx +72 -0
  80. package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +80 -11
  81. package/deps/couchbase-cxx-client/couchbase/create_collection_options.hxx +29 -1
  82. package/deps/couchbase-cxx-client/couchbase/diagnostics_options.hxx +75 -0
  83. package/deps/couchbase-cxx-client/couchbase/diagnostics_result.hxx +124 -0
  84. package/deps/couchbase-cxx-client/couchbase/endpoint_diagnostics.hxx +206 -0
  85. package/deps/couchbase-cxx-client/couchbase/endpoint_ping_report.hxx +205 -0
  86. package/deps/couchbase-cxx-client/couchbase/fmt/key_value_status_code.hxx +3 -1
  87. package/deps/couchbase-cxx-client/couchbase/get_options.hxx +1 -6
  88. package/deps/couchbase-cxx-client/couchbase/key_value_status_code.hxx +1 -0
  89. package/deps/couchbase-cxx-client/couchbase/management/collection_spec.hxx +1 -1
  90. package/deps/couchbase-cxx-client/couchbase/ping_options.hxx +93 -0
  91. package/deps/couchbase-cxx-client/couchbase/ping_result.hxx +118 -0
  92. package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +6 -8
  93. package/deps/couchbase-cxx-client/couchbase/scope.hxx +24 -8
  94. package/deps/couchbase-cxx-client/couchbase/scope_search_index_manager.hxx +291 -0
  95. package/deps/couchbase-cxx-client/couchbase/search_request.hxx +120 -0
  96. package/deps/couchbase-cxx-client/couchbase/service_type.hxx +58 -0
  97. package/deps/couchbase-cxx-client/couchbase/update_collection_options.hxx +32 -3
  98. package/deps/couchbase-cxx-client/couchbase/vector_query.hxx +99 -0
  99. package/deps/couchbase-cxx-client/couchbase/vector_search.hxx +85 -0
  100. package/deps/couchbase-cxx-client/couchbase/vector_search_options.hxx +76 -0
  101. package/dist/binding.d.ts +33 -2
  102. package/dist/binding.js +4 -1
  103. package/dist/bindingutilities.d.ts +16 -3
  104. package/dist/bindingutilities.js +47 -7
  105. package/dist/cluster.d.ts +12 -1
  106. package/dist/cluster.js +22 -0
  107. package/dist/couchbase.d.ts +2 -0
  108. package/dist/couchbase.js +2 -0
  109. package/dist/queryindexmanager.d.ts +4 -4
  110. package/dist/queryindexmanager.js +7 -7
  111. package/dist/scope.d.ts +21 -0
  112. package/dist/scope.js +34 -0
  113. package/dist/scopesearchindexmanager.d.ts +116 -0
  114. package/dist/scopesearchindexmanager.js +406 -0
  115. package/dist/sdspecs.js +10 -9
  116. package/dist/sdutils.d.ts +1 -0
  117. package/dist/sdutils.js +4 -0
  118. package/dist/searchexecutor.d.ts +5 -3
  119. package/dist/searchexecutor.js +27 -4
  120. package/dist/searchindexmanager.d.ts +58 -3
  121. package/dist/searchindexmanager.js +188 -104
  122. package/dist/searchtypes.d.ts +46 -0
  123. package/dist/searchtypes.js +81 -1
  124. package/dist/vectorsearch.d.ts +99 -0
  125. package/dist/vectorsearch.js +132 -0
  126. package/dist/viewexecutor.js +13 -9
  127. package/dist/viewindexmanager.d.ts +70 -7
  128. package/dist/viewindexmanager.js +236 -103
  129. package/dist/viewtypes.d.ts +26 -0
  130. package/dist/viewtypes.js +17 -1
  131. package/package.json +7 -7
  132. package/src/constants.cpp +12 -0
  133. package/src/jstocbpp_autogen.hpp +113 -13
  134. package/tools/gen-bindings-json.py +2 -0
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SearchExecutor = void 0;
4
4
  /* eslint jsdoc/require-jsdoc: off */
5
5
  const bindingutilities_1 = require("./bindingutilities");
6
+ const searchquery_1 = require("./searchquery");
6
7
  const searchtypes_1 = require("./searchtypes");
7
8
  const streamablepromises_1 = require("./streamablepromises");
8
9
  /**
@@ -12,8 +13,10 @@ class SearchExecutor {
12
13
  /**
13
14
  * @internal
14
15
  */
15
- constructor(cluster) {
16
+ constructor(cluster, bucketName, scopeName) {
16
17
  this._cluster = cluster;
18
+ this._bucketName = bucketName;
19
+ this._scopeName = scopeName;
17
20
  }
18
21
  /**
19
22
  * @internal
@@ -25,11 +28,16 @@ class SearchExecutor {
25
28
  meta: meta,
26
29
  });
27
30
  });
31
+ const searchQuery = query instanceof searchquery_1.SearchQuery
32
+ ? JSON.stringify(query)
33
+ : query.searchQuery
34
+ ? JSON.stringify(query.searchQuery)
35
+ : JSON.stringify(new searchquery_1.MatchNoneSearchQuery());
28
36
  const timeout = options.timeout || this._cluster.searchTimeout;
29
- this._cluster.conn.search({
37
+ const request = {
30
38
  timeout,
31
39
  index_name: indexName,
32
- query: JSON.stringify(query),
40
+ query: searchQuery,
33
41
  limit: options.limit,
34
42
  skip: options.skip,
35
43
  explain: options.explain || false,
@@ -59,7 +67,22 @@ class SearchExecutor {
59
67
  .map(([k, v]) => [k, JSON.stringify(v)]))
60
68
  : {},
61
69
  body_str: '',
62
- }, (cppErr, resp) => {
70
+ };
71
+ if (query instanceof searchtypes_1.SearchRequest) {
72
+ request.show_request = false;
73
+ if (query.vectorSearch) {
74
+ request.vector_search = JSON.stringify(query.vectorSearch.queries);
75
+ if (query.vectorSearch.options &&
76
+ query.vectorSearch.options.vectorQueryCombination) {
77
+ request.vector_query_combination = (0, bindingutilities_1.vectorQueryCombinationToCpp)(query.vectorSearch.options.vectorQueryCombination);
78
+ }
79
+ }
80
+ }
81
+ if (this._bucketName && this._scopeName) {
82
+ request.bucket_name = this._bucketName;
83
+ request.scope_name = this._scopeName;
84
+ }
85
+ this._cluster.conn.search(request, (cppErr, resp) => {
63
86
  const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
64
87
  if (err) {
65
88
  emitter.emit('error', err);
@@ -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<void>): Promise<void>;
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.wrapAsync(async () => {
55
- const res = await this._http.request({
56
- type: httpexecutor_1.HttpServiceType.Search,
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.wrapAsync(async () => {
84
- const res = await this._http.request({
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.wrapAsync(async () => {
115
- const res = await this._http.request({
116
- type: httpexecutor_1.HttpServiceType.Search,
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.wrapAsync(async () => {
145
- const res = await this._http.request({
146
- type: httpexecutor_1.HttpServiceType.Search,
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.wrapAsync(async () => {
174
- const res = await this._http.request({
175
- type: httpexecutor_1.HttpServiceType.Search,
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.wrapAsync(async () => {
203
- const res = await this._http.request({
204
- type: httpexecutor_1.HttpServiceType.Search,
205
- method: httpexecutor_1.HttpMethod.Post,
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.wrapAsync(async () => {
231
- const res = await this._http.request({
232
- type: httpexecutor_1.HttpServiceType.Search,
233
- method: httpexecutor_1.HttpMethod.Post,
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.wrapAsync(async () => {
259
- const res = await this._http.request({
260
- type: httpexecutor_1.HttpServiceType.Search,
261
- method: httpexecutor_1.HttpMethod.Post,
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.wrapAsync(async () => {
287
- const res = await this._http.request({
288
- type: httpexecutor_1.HttpServiceType.Search,
289
- method: httpexecutor_1.HttpMethod.Post,
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.wrapAsync(async () => {
315
- const res = await this._http.request({
316
- type: httpexecutor_1.HttpServiceType.Search,
317
- method: httpexecutor_1.HttpMethod.Post,
318
- path: `/api/index/${indexName}/planFreezeControl/freeze`,
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.wrapAsync(async () => {
344
- const res = await this._http.request({
345
- type: httpexecutor_1.HttpServiceType.Search,
346
- method: httpexecutor_1.HttpMethod.Post,
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
  }
@@ -1,6 +1,8 @@
1
1
  import { MutationState } from './mutationstate';
2
2
  import { SearchFacet } from './searchfacet';
3
+ import { SearchQuery } from './searchquery';
3
4
  import { SearchSort } from './searchsort';
5
+ import { VectorSearch } from './vectorsearch';
4
6
  /**
5
7
  * SearchMetaData represents the meta-data available from a search query.
6
8
  * This class is currently incomplete and must be casted to `any` in
@@ -145,3 +147,47 @@ export interface SearchQueryOptions {
145
147
  */
146
148
  timeout?: number;
147
149
  }
150
+ /**
151
+ * Represents a search query and/or vector search to execute via the Couchbase Full Text Search (FTS) service.
152
+ *
153
+ * Volatile: This API is subject to change at any time.
154
+ *
155
+ * @category Full Text Search
156
+ */
157
+ export declare class SearchRequest {
158
+ private _searchQuery;
159
+ private _vectorSearch;
160
+ constructor(query: SearchQuery | VectorSearch);
161
+ /**
162
+ * @internal
163
+ */
164
+ get searchQuery(): SearchQuery | undefined;
165
+ /**
166
+ * @internal
167
+ */
168
+ get vectorSearch(): VectorSearch | undefined;
169
+ /**
170
+ * Adds a search query to the request if the request does not already have a search query.
171
+ *
172
+ * Volatile: This API is subject to change at any time.
173
+ *
174
+ * @param query A SearchQuery to add to the request.
175
+ */
176
+ withSearchQuery(query: SearchQuery): SearchRequest;
177
+ /**
178
+ * Adds a vector search to the request if the request does not already have a vector search.
179
+ *
180
+ * Volatile: This API is subject to change at any time.
181
+ *
182
+ * @param search A VectorSearch to add to the request.
183
+ */
184
+ withVectorSearch(search: VectorSearch): SearchRequest;
185
+ /**
186
+ * Creates a search request.
187
+ *
188
+ * Volatile: This API is subject to change at any time.
189
+ *
190
+ * @param query Either a SearchQuery or VectorSearch to add to the search request.
191
+ */
192
+ static create(query: SearchQuery | VectorSearch): SearchRequest;
193
+ }