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
@@ -0,0 +1,294 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #include "diagnostics.hxx"
19
+
20
+ #include "core/diagnostics.hxx"
21
+ #include "core/service_type.hxx"
22
+
23
+ #include <couchbase/codec/tao_json_serializer.hxx>
24
+ #include <couchbase/diagnostics_result.hxx>
25
+ #include <couchbase/endpoint_ping_report.hxx>
26
+ #include <couchbase/ping_result.hxx>
27
+ #include <couchbase/service_type.hxx>
28
+
29
+ #include <cstdint>
30
+ #include <map>
31
+ #include <set>
32
+ #include <string>
33
+ #include <vector>
34
+
35
+ namespace couchbase
36
+ {
37
+ namespace
38
+ {
39
+ std::string
40
+ service_type_as_string(service_type service_type)
41
+ {
42
+ switch (service_type) {
43
+ case service_type::key_value:
44
+ return "kv";
45
+ case service_type::query:
46
+ return "query";
47
+ case service_type::analytics:
48
+ return "analytics";
49
+ case service_type::search:
50
+ return "search";
51
+ case service_type::view:
52
+ return "views";
53
+ case service_type::management:
54
+ return "mgmt";
55
+ case service_type::eventing:
56
+ return "eventing";
57
+ }
58
+ return "";
59
+ }
60
+
61
+ std::string
62
+ ping_state_as_string(ping_state state)
63
+ {
64
+ switch (state) {
65
+ case ping_state::ok:
66
+ return "ok";
67
+ case ping_state::timeout:
68
+ return "timeout";
69
+ case ping_state::error:
70
+ return "error";
71
+ }
72
+ return "";
73
+ }
74
+
75
+ std::string
76
+ endpoint_state_as_string(endpoint_state state)
77
+ {
78
+ switch (state) {
79
+ case endpoint_state::connected:
80
+ return "connected";
81
+ case endpoint_state::connecting:
82
+ return "connecting";
83
+ case endpoint_state::disconnected:
84
+ return "disconnected";
85
+ case endpoint_state::disconnecting:
86
+ return "disconnecting";
87
+ }
88
+ return "";
89
+ }
90
+
91
+ codec::tao_json_serializer::document_type
92
+ endpoint_ping_report_as_json(const endpoint_ping_report& report)
93
+ {
94
+ codec::tao_json_serializer::document_type res{
95
+ { "id", report.id() }, { "latency_us", report.latency().count() }, { "remote", report.remote() },
96
+ { "local", report.local() }, { "state", ping_state_as_string(report.state()) },
97
+ };
98
+ if (report.error()) {
99
+ res["error"] = report.error().value();
100
+ }
101
+ if (report.endpoint_namespace()) {
102
+ res["namespace"] = report.endpoint_namespace().value();
103
+ }
104
+ return res;
105
+ }
106
+
107
+ codec::tao_json_serializer::document_type
108
+ endpoint_diagnostics_as_json(const endpoint_diagnostics& report)
109
+ {
110
+ codec::tao_json_serializer::document_type res{
111
+ { "id", report.id() },
112
+ { "local", report.local() },
113
+ { "remote", report.remote() },
114
+ { "state", endpoint_state_as_string(report.state()) },
115
+ };
116
+ if (report.last_activity()) {
117
+ res["last_activity_us"] = report.last_activity().value().count();
118
+ }
119
+ if (report.endpoint_namespace()) {
120
+ res["namespace"] = report.endpoint_namespace().value();
121
+ }
122
+ if (report.details()) {
123
+ res["details"] = report.details();
124
+ }
125
+ return res;
126
+ }
127
+ } // namespace
128
+
129
+ auto
130
+ ping_result::as_json() const -> codec::tao_json_serializer::document_type
131
+ {
132
+ codec::tao_json_serializer::document_type endpoints{};
133
+ for (const auto& [service_type, reports] : endpoints_) {
134
+ std::vector<codec::tao_json_serializer::document_type> json_reports{};
135
+ for (const auto& report : reports) {
136
+ json_reports.emplace_back(endpoint_ping_report_as_json(report));
137
+ }
138
+ endpoints[service_type_as_string(service_type)] = json_reports;
139
+ }
140
+ return {
141
+ { "version", version_ },
142
+ { "id", id_ },
143
+ { "sdk", sdk_ },
144
+ { "services", endpoints },
145
+ };
146
+ }
147
+
148
+ auto
149
+ diagnostics_result::as_json() const -> codec::tao_json_serializer::document_type
150
+ {
151
+ codec::tao_json_serializer::document_type endpoints{};
152
+ for (const auto& [service_type, reports] : endpoints_) {
153
+ std::vector<codec::tao_json_serializer::document_type> json_reports{};
154
+ for (const auto& report : reports) {
155
+ json_reports.emplace_back(endpoint_diagnostics_as_json(report));
156
+ }
157
+ endpoints[service_type_as_string(service_type)] = json_reports;
158
+ }
159
+ return {
160
+ { "id", id_ },
161
+ { "sdk", sdk_ },
162
+ { "version", version_ },
163
+ { "services", endpoints },
164
+ };
165
+ }
166
+ } // namespace couchbase
167
+
168
+ namespace couchbase::core::impl
169
+ {
170
+ namespace
171
+ {
172
+ couchbase::service_type
173
+ to_public_service_type(core::service_type service_type)
174
+ {
175
+ switch (service_type) {
176
+ case core::service_type::key_value:
177
+ return couchbase::service_type::key_value;
178
+ case core::service_type::query:
179
+ return couchbase::service_type::query;
180
+ case core::service_type::analytics:
181
+ return couchbase::service_type::analytics;
182
+ case core::service_type::search:
183
+ return couchbase::service_type::search;
184
+ case core::service_type::view:
185
+ return couchbase::service_type::view;
186
+ case core::service_type::management:
187
+ return couchbase::service_type::management;
188
+ case core::service_type::eventing:
189
+ return couchbase::service_type::eventing;
190
+ }
191
+ return {};
192
+ }
193
+
194
+ couchbase::ping_state
195
+ to_public_ping_state(core::diag::ping_state ping_state)
196
+ {
197
+ switch (ping_state) {
198
+ case core::diag::ping_state::timeout:
199
+ return couchbase::ping_state::timeout;
200
+ case core::diag::ping_state::error:
201
+ return couchbase::ping_state::error;
202
+ case core::diag::ping_state::ok:
203
+ return couchbase::ping_state::ok;
204
+ }
205
+ return {};
206
+ }
207
+
208
+ couchbase::endpoint_state
209
+ to_public_endpoint_state(core::diag::endpoint_state endpoint_state)
210
+ {
211
+ switch (endpoint_state) {
212
+ case core::diag::endpoint_state::connected:
213
+ return couchbase::endpoint_state::connected;
214
+ case diag::endpoint_state::disconnected:
215
+ return couchbase::endpoint_state::disconnected;
216
+ case diag::endpoint_state::connecting:
217
+ return couchbase::endpoint_state::connecting;
218
+ case diag::endpoint_state::disconnecting:
219
+ return couchbase::endpoint_state::disconnecting;
220
+ }
221
+ return {};
222
+ }
223
+ } // namespace
224
+
225
+ std::set<core::service_type>
226
+ to_core_service_types(const std::set<couchbase::service_type>& service_types)
227
+ {
228
+ std::set<core::service_type> res{};
229
+ for (auto s : service_types) {
230
+ switch (s) {
231
+ case couchbase::service_type::key_value:
232
+ res.emplace(core::service_type::key_value);
233
+ break;
234
+ case couchbase::service_type::query:
235
+ res.emplace(core::service_type::query);
236
+ break;
237
+ case couchbase::service_type::analytics:
238
+ res.emplace(core::service_type::analytics);
239
+ break;
240
+ case couchbase::service_type::search:
241
+ res.emplace(core::service_type::search);
242
+ break;
243
+ case couchbase::service_type::view:
244
+ res.emplace(core::service_type::view);
245
+ break;
246
+ case couchbase::service_type::management:
247
+ res.emplace(core::service_type::management);
248
+ break;
249
+ case couchbase::service_type::eventing:
250
+ res.emplace(core::service_type::eventing);
251
+ break;
252
+ }
253
+ }
254
+ return res;
255
+ }
256
+
257
+ couchbase::ping_result
258
+ build_result(const core::diag::ping_result& result)
259
+ {
260
+ std::map<couchbase::service_type, std::vector<couchbase::endpoint_ping_report>> endpoints{};
261
+ for (const auto& [core_service_type, core_endpoints] : result.services) {
262
+ auto service_type = to_public_service_type(core_service_type);
263
+ endpoints[service_type] = std::vector<couchbase::endpoint_ping_report>{};
264
+ for (const auto& info : core_endpoints) {
265
+ endpoints[service_type].emplace_back(
266
+ service_type, info.id, info.local, info.remote, to_public_ping_state(info.state), info.error, info.bucket, info.latency);
267
+ }
268
+ }
269
+
270
+ return { result.id, static_cast<std::uint16_t>(result.version), result.sdk, endpoints };
271
+ }
272
+
273
+ couchbase::diagnostics_result
274
+ build_result(const core::diag::diagnostics_result& result)
275
+ {
276
+ std::map<couchbase::service_type, std::vector<couchbase::endpoint_diagnostics>> endpoints{};
277
+ for (const auto& [core_service_type, core_endpoints] : result.services) {
278
+ auto service_type = to_public_service_type(core_service_type);
279
+ endpoints[service_type] = std::vector<couchbase::endpoint_diagnostics>{};
280
+ for (const auto& info : core_endpoints) {
281
+ endpoints[service_type].emplace_back(service_type,
282
+ info.id,
283
+ info.last_activity,
284
+ info.local,
285
+ info.remote,
286
+ info.bucket,
287
+ to_public_endpoint_state(info.state),
288
+ info.details);
289
+ }
290
+ }
291
+
292
+ return { result.id, static_cast<std::uint16_t>(result.version), result.sdk, endpoints };
293
+ }
294
+ } // namespace couchbase::core::impl
@@ -0,0 +1,39 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-Present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ #include <couchbase/diagnostics_result.hxx>
21
+ #include <couchbase/ping_result.hxx>
22
+ #include <couchbase/service_type.hxx>
23
+
24
+ #include "core/diagnostics.hxx"
25
+ #include "core/service_type.hxx"
26
+
27
+ #include <set>
28
+
29
+ namespace couchbase::core::impl
30
+ {
31
+ std::set<core::service_type>
32
+ to_core_service_types(const std::set<couchbase::service_type>& service_types);
33
+
34
+ couchbase::ping_result
35
+ build_result(const core::diag::ping_result& result);
36
+
37
+ couchbase::diagnostics_result
38
+ build_result(const core::diag::diagnostics_result& result);
39
+ } // namespace couchbase::core::impl
@@ -215,7 +215,7 @@ class query_index_manager_impl : public std::enable_shared_from_this<query_index
215
215
  const std::string& scope_name,
216
216
  const std::string& collection_name,
217
217
  std::string index_name,
218
- std::vector<std::string> fields,
218
+ std::vector<std::string> keys,
219
219
  const create_query_index_options::built& options,
220
220
  create_query_index_handler&& handler) const
221
221
  {
@@ -225,7 +225,7 @@ class query_index_manager_impl : public std::enable_shared_from_this<query_index
225
225
  scope_name,
226
226
  collection_name,
227
227
  std::move(index_name),
228
- std::move(fields),
228
+ std::move(keys),
229
229
  {},
230
230
  false /* is_primary */,
231
231
  options.ignore_if_exists,
@@ -521,22 +521,22 @@ collection_query_index_manager::get_all_indexes(const get_all_query_indexes_opti
521
521
 
522
522
  void
523
523
  collection_query_index_manager::create_index(std::string index_name,
524
- std::vector<std::string> fields,
524
+ std::vector<std::string> keys,
525
525
  const create_query_index_options& options,
526
526
  create_query_index_handler&& handler) const
527
527
  {
528
528
  return impl_->create_index(
529
- bucket_name_, scope_name_, collection_name_, std::move(index_name), std::move(fields), options.build(), std::move(handler));
529
+ bucket_name_, scope_name_, collection_name_, std::move(index_name), std::move(keys), options.build(), std::move(handler));
530
530
  }
531
531
 
532
532
  auto
533
533
  collection_query_index_manager::create_index(std::string index_name,
534
- std::vector<std::string> fields,
534
+ std::vector<std::string> keys,
535
535
  const create_query_index_options& options) const -> std::future<manager_error_context>
536
536
  {
537
537
  auto barrier = std::make_shared<std::promise<manager_error_context>>();
538
538
  auto future = barrier->get_future();
539
- create_index(std::move(index_name), std::move(fields), options, [barrier](auto ctx) { barrier->set_value(std::move(ctx)); });
539
+ create_index(std::move(index_name), std::move(keys), options, [barrier](auto ctx) { barrier->set_value(std::move(ctx)); });
540
540
  return future;
541
541
  }
542
542
 
@@ -89,6 +89,15 @@ class scope_impl
89
89
  });
90
90
  }
91
91
 
92
+ void search(std::string index_name, couchbase::search_request request, search_options::built options, search_handler&& handler) const
93
+ {
94
+ return core_.execute(core::impl::build_search_request(std::move(index_name), std::move(request), options, bucket_name_, name_),
95
+ [handler = std::move(handler)](auto&& resp) mutable {
96
+ return handler(search_error_context{ internal_search_error_context{ resp } },
97
+ search_result{ internal_search_result{ resp } });
98
+ });
99
+ }
100
+
92
101
  private:
93
102
  core::cluster core_;
94
103
  std::string bucket_name_;
@@ -153,20 +162,26 @@ scope::analytics_query(std::string statement, const analytics_options& options)
153
162
  }
154
163
 
155
164
  void
156
- scope::search_query(std::string index_name, const class search_query& query, const search_options& options, search_handler&& handler) const
165
+ scope::search(std::string index_name, search_request request, const search_options& options, search_handler&& handler) const
157
166
  {
158
- return impl_->search_query(std::move(index_name), query, options.build(), std::move(handler));
167
+ return impl_->search(std::move(index_name), std::move(request), options.build(), std::move(handler));
159
168
  }
160
169
 
161
170
  auto
162
- scope::search_query(std::string index_name, const class search_query& query, const search_options& options) const
171
+ scope::search(std::string index_name, search_request request, const search_options& options) const
163
172
  -> std::future<std::pair<search_error_context, search_result>>
164
173
  {
165
174
  auto barrier = std::make_shared<std::promise<std::pair<search_error_context, search_result>>>();
166
175
  auto future = barrier->get_future();
167
- search_query(std::move(index_name), query, options, [barrier](auto ctx, auto result) {
176
+ search(std::move(index_name), std::move(request), options, [barrier](auto ctx, auto result) {
168
177
  barrier->set_value({ std::move(ctx), std::move(result) });
169
178
  });
170
179
  return future;
171
180
  }
181
+
182
+ auto
183
+ scope::search_indexes() const -> scope_search_index_manager
184
+ {
185
+ return scope_search_index_manager{ impl_->core(), impl_->bucket_name(), impl_->name() };
186
+ }
172
187
  } // namespace couchbase
@@ -26,6 +26,8 @@
26
26
  #include "internal_term_facet_result.hxx"
27
27
 
28
28
  #include <couchbase/cluster.hxx>
29
+ #include <couchbase/match_none_query.hxx>
30
+ #include <utility>
29
31
 
30
32
  #include <fmt/core.h>
31
33
 
@@ -102,14 +104,29 @@ map_raw(std::map<std::string, codec::binary, std::less<>>& raw)
102
104
  }
103
105
  return core_raw;
104
106
  }
107
+
108
+ static std::optional<core::vector_query_combination>
109
+ map_vector_query_combination(const std::optional<couchbase::vector_query_combination>& combination)
110
+ {
111
+ if (combination) {
112
+ switch (combination.value()) {
113
+ case couchbase::vector_query_combination::combination_and:
114
+ return core::vector_query_combination::combination_and;
115
+ case couchbase::vector_query_combination::combination_or:
116
+ return core::vector_query_combination::combination_or;
117
+ }
118
+ }
119
+ return {};
120
+ }
121
+
105
122
  } // namespace
106
123
 
107
124
  core::operations::search_request
108
125
  build_search_request(std::string index_name,
109
126
  const search_query& query,
110
127
  search_options::built options,
111
- std::optional<std::string> /* bucket_name */,
112
- std::optional<std::string> /* scope_name */)
128
+ std::optional<std::string> bucket_name,
129
+ std::optional<std::string> scope_name)
113
130
  {
114
131
  auto encoded = query.encode();
115
132
  if (encoded.ec) {
@@ -118,6 +135,11 @@ build_search_request(std::string index_name,
118
135
  core::operations::search_request request{
119
136
  std::move(index_name),
120
137
  core::utils::json::generate_binary(encoded.query),
138
+ std::move(bucket_name),
139
+ std::move(scope_name),
140
+ {},
141
+ {},
142
+ {},
121
143
  options.limit,
122
144
  options.skip,
123
145
  options.explain,
@@ -139,4 +161,55 @@ build_search_request(std::string index_name,
139
161
  return request;
140
162
  }
141
163
 
164
+ core::operations::search_request
165
+ build_search_request(std::string index_name,
166
+ couchbase::search_request request,
167
+ search_options::built options,
168
+ std::optional<std::string> bucket_name,
169
+ std::optional<std::string> scope_name)
170
+ {
171
+ if (!request.search_query().has_value()) {
172
+ request.search_query(couchbase::match_none_query{});
173
+ }
174
+
175
+ core::operations::search_request core_request{
176
+ std::move(index_name),
177
+ core::utils::json::generate_binary(request.search_query().value().query),
178
+ std::move(bucket_name),
179
+ std::move(scope_name),
180
+ false,
181
+ {},
182
+ {},
183
+ options.limit,
184
+ options.skip,
185
+ options.explain,
186
+ options.disable_scoring,
187
+ options.include_locations,
188
+ map_highlight_style(options.highlight_style),
189
+ options.highlight_fields,
190
+ options.fields,
191
+ options.collections,
192
+ map_scan_consistency(options.scan_consistency),
193
+ options.mutation_state,
194
+ map_sort(options.sort, options.sort_string),
195
+ map_facets(options.facets),
196
+ map_raw(options.raw),
197
+ {},
198
+ options.client_context_id,
199
+ options.timeout,
200
+ };
201
+
202
+ if (!request.vector_search().has_value()) {
203
+ return core_request;
204
+ }
205
+ core_request.vector_search = core::utils::json::generate_binary(request.vector_search().value().query);
206
+
207
+ auto vector_search_options = request.vector_options();
208
+ if (!vector_search_options.has_value()) {
209
+ return core_request;
210
+ }
211
+
212
+ core_request.vector_query_combination = map_vector_query_combination(vector_search_options.value().combination);
213
+ return core_request;
214
+ }
142
215
  } // namespace couchbase::core::impl
@@ -21,6 +21,7 @@
21
21
 
22
22
  #include <couchbase/search_options.hxx>
23
23
  #include <couchbase/search_query.hxx>
24
+ #include <couchbase/search_request.hxx>
24
25
 
25
26
  #include <optional>
26
27
  #include <string>
@@ -34,4 +35,11 @@ build_search_request(std::string index_name,
34
35
  std::optional<std::string> bucket_name,
35
36
  std::optional<std::string> scope_name);
36
37
 
38
+ core::operations::search_request
39
+ build_search_request(std::string index_name,
40
+ search_request request,
41
+ search_options::built options,
42
+ std::optional<std::string> bucket_name,
43
+ std::optional<std::string> scope_name);
44
+
37
45
  } // namespace couchbase::core::impl