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.
- package/deps/couchbase-cxx-client/CMakeLists.txt +4 -0
- package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +7 -3
- package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +1 -0
- package/deps/couchbase-cxx-client/core/bucket.cxx +67 -2
- package/deps/couchbase-cxx-client/core/bucket.hxx +2 -1
- package/deps/couchbase-cxx-client/core/cluster.cxx +65 -1
- package/deps/couchbase-cxx-client/core/impl/bucket.cxx +24 -0
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +73 -0
- package/deps/couchbase-cxx-client/core/impl/collection.cxx +2 -2
- package/deps/couchbase-cxx-client/core/impl/diagnostics.cxx +294 -0
- package/deps/couchbase-cxx-client/core/impl/diagnostics.hxx +39 -0
- package/deps/couchbase-cxx-client/core/impl/query_index_manager.cxx +6 -6
- package/deps/couchbase-cxx-client/core/impl/scope.cxx +19 -4
- package/deps/couchbase-cxx-client/core/impl/search.cxx +75 -2
- package/deps/couchbase-cxx-client/core/impl/search.hxx +8 -0
- package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +261 -18
- package/deps/couchbase-cxx-client/core/impl/search_request.cxx +139 -0
- package/deps/couchbase-cxx-client/core/impl/vector_query.cxx +42 -0
- package/deps/couchbase-cxx-client/core/impl/vector_search.cxx +40 -0
- package/deps/couchbase-cxx-client/core/io/http_session.hxx +6 -3
- 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 +48 -33
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +2 -0
- package/deps/couchbase-cxx-client/core/logger/logger.cxx +1 -1
- package/deps/couchbase-cxx-client/core/management/design_document.hxx +1 -1
- package/deps/couchbase-cxx-client/core/meta/features.hxx +26 -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 +8 -3
- package/deps/couchbase-cxx-client/core/operations/document_search.cxx +37 -1
- package/deps/couchbase-cxx-client/core/operations/document_search.hxx +11 -0
- 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/collection_create.cxx +7 -6
- package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +7 -8
- package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +1 -1
- package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +3 -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/operations/management/search_index_analyze_document.cxx +17 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +21 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +21 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +21 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +17 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +17 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +39 -22
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +18 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +3 -0
- package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +17 -1
- package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +3 -0
- 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/topology/capabilities.hxx +70 -1
- package/deps/couchbase-cxx-client/core/topology/capabilities_fmt.hxx +30 -2
- package/deps/couchbase-cxx-client/core/topology/collections_manifest.hxx +1 -1
- package/deps/couchbase-cxx-client/core/topology/collections_manifest_json.hxx +1 -1
- 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/core/transactions/internal/utils.hxx +4 -0
- package/deps/couchbase-cxx-client/core/vector_query_combination.hxx +23 -0
- package/deps/couchbase-cxx-client/couchbase/bucket.hxx +29 -0
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +110 -0
- package/deps/couchbase-cxx-client/couchbase/codec/json_transcoder.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/codec/raw_binary_transcoder.hxx +2 -1
- package/deps/couchbase-cxx-client/couchbase/codec/raw_json_transcoder.hxx +78 -0
- package/deps/couchbase-cxx-client/couchbase/codec/raw_string_transcoder.hxx +72 -0
- package/deps/couchbase-cxx-client/couchbase/collection_query_index_manager.hxx +80 -11
- package/deps/couchbase-cxx-client/couchbase/create_collection_options.hxx +29 -1
- package/deps/couchbase-cxx-client/couchbase/diagnostics_options.hxx +75 -0
- package/deps/couchbase-cxx-client/couchbase/diagnostics_result.hxx +124 -0
- package/deps/couchbase-cxx-client/couchbase/endpoint_diagnostics.hxx +206 -0
- package/deps/couchbase-cxx-client/couchbase/endpoint_ping_report.hxx +205 -0
- package/deps/couchbase-cxx-client/couchbase/fmt/key_value_status_code.hxx +3 -1
- package/deps/couchbase-cxx-client/couchbase/get_options.hxx +1 -6
- package/deps/couchbase-cxx-client/couchbase/key_value_status_code.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/management/collection_spec.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/ping_options.hxx +93 -0
- package/deps/couchbase-cxx-client/couchbase/ping_result.hxx +118 -0
- package/deps/couchbase-cxx-client/couchbase/query_index_manager.hxx +6 -8
- package/deps/couchbase-cxx-client/couchbase/scope.hxx +24 -8
- package/deps/couchbase-cxx-client/couchbase/scope_search_index_manager.hxx +291 -0
- package/deps/couchbase-cxx-client/couchbase/search_request.hxx +120 -0
- package/deps/couchbase-cxx-client/couchbase/service_type.hxx +58 -0
- package/deps/couchbase-cxx-client/couchbase/update_collection_options.hxx +32 -3
- package/deps/couchbase-cxx-client/couchbase/vector_query.hxx +99 -0
- package/deps/couchbase-cxx-client/couchbase/vector_search.hxx +85 -0
- package/deps/couchbase-cxx-client/couchbase/vector_search_options.hxx +76 -0
- package/dist/binding.d.ts +33 -2
- package/dist/binding.js +4 -1
- package/dist/bindingutilities.d.ts +16 -3
- package/dist/bindingutilities.js +47 -7
- package/dist/cluster.d.ts +12 -1
- package/dist/cluster.js +22 -0
- package/dist/couchbase.d.ts +2 -0
- package/dist/couchbase.js +2 -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 +5 -3
- package/dist/searchexecutor.js +27 -4
- package/dist/searchindexmanager.d.ts +58 -3
- package/dist/searchindexmanager.js +188 -104
- package/dist/searchtypes.d.ts +46 -0
- package/dist/searchtypes.js +81 -1
- package/dist/vectorsearch.d.ts +99 -0
- package/dist/vectorsearch.js +132 -0
- 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 +12 -0
- package/src/jstocbpp_autogen.hpp +113 -13
- package/tools/gen-bindings-json.py +2 -0
@@ -29,6 +29,7 @@
|
|
29
29
|
#include "core/utils/json.hxx"
|
30
30
|
#include "internal_manager_error_context.hxx"
|
31
31
|
|
32
|
+
#include <couchbase/scope_search_index_manager.hxx>
|
32
33
|
#include <couchbase/search_index_manager.hxx>
|
33
34
|
|
34
35
|
#include <memory>
|
@@ -145,19 +146,26 @@ class search_index_manager_impl
|
|
145
146
|
{
|
146
147
|
}
|
147
148
|
|
149
|
+
explicit search_index_manager_impl(core::cluster core, std::string bucket_name, std::string scope_name)
|
150
|
+
: core_{ std::move(core) }
|
151
|
+
, bucket_name_{ std::move(bucket_name) }
|
152
|
+
, scope_name_{ std::move(scope_name) }
|
153
|
+
{
|
154
|
+
}
|
155
|
+
|
148
156
|
void get_index(std::string index_name,
|
149
157
|
const couchbase::get_search_index_options::built& options,
|
150
158
|
get_search_index_handler&& handler) const
|
151
159
|
{
|
152
160
|
core_.execute(
|
153
|
-
core::operations::management::search_index_get_request{ std::move(index_name), {}, options.timeout },
|
161
|
+
core::operations::management::search_index_get_request{ std::move(index_name), bucket_name_, scope_name_, {}, options.timeout },
|
154
162
|
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp), map_search_index(resp.index)); });
|
155
163
|
}
|
156
164
|
|
157
165
|
void get_all_indexes(const get_all_search_indexes_options::built& options, get_all_search_indexes_handler&& handler) const
|
158
166
|
{
|
159
167
|
core_.execute(
|
160
|
-
core::operations::management::search_index_get_all_request{ {}, options.timeout },
|
168
|
+
core::operations::management::search_index_get_all_request{ bucket_name_, scope_name_, {}, options.timeout },
|
161
169
|
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp), map_all_search_indexes(resp.indexes)); });
|
162
170
|
}
|
163
171
|
|
@@ -165,30 +173,37 @@ class search_index_manager_impl
|
|
165
173
|
const upsert_search_index_options::built& options,
|
166
174
|
upsert_search_index_handler&& handler) const
|
167
175
|
{
|
168
|
-
core_.execute(
|
169
|
-
|
176
|
+
core_.execute(
|
177
|
+
core::operations::management::search_index_upsert_request{
|
178
|
+
map_search_index(search_index), bucket_name_, scope_name_, {}, options.timeout },
|
179
|
+
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp)); });
|
170
180
|
}
|
171
181
|
|
172
182
|
void drop_index(std::string index_name, const drop_search_index_options::built& options, drop_search_index_handler&& handler) const
|
173
183
|
{
|
174
|
-
core_.execute(
|
175
|
-
|
184
|
+
core_.execute(
|
185
|
+
core::operations::management::search_index_drop_request{ std::move(index_name), bucket_name_, scope_name_, {}, options.timeout },
|
186
|
+
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp)); });
|
176
187
|
}
|
177
188
|
|
178
189
|
void get_indexed_documents_count(std::string index_name,
|
179
190
|
const get_indexed_search_index_options::built& options,
|
180
191
|
get_indexed_search_index_handler&& handler) const
|
181
192
|
{
|
182
|
-
core_.execute(
|
183
|
-
|
193
|
+
core_.execute(
|
194
|
+
core::operations::management::search_index_get_documents_count_request{
|
195
|
+
std::move(index_name), bucket_name_, scope_name_, {}, options.timeout },
|
196
|
+
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp), resp.count); });
|
184
197
|
}
|
185
198
|
|
186
199
|
void pause_ingest(std::string index_name,
|
187
200
|
const pause_ingest_search_index_options::built& options,
|
188
201
|
pause_ingest_search_index_handler&& handler) const
|
189
202
|
{
|
190
|
-
core_.execute(
|
191
|
-
|
203
|
+
core_.execute(
|
204
|
+
core::operations::management::search_index_control_ingest_request{
|
205
|
+
std::move(index_name), true, bucket_name_, scope_name_, {}, options.timeout },
|
206
|
+
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp)); });
|
192
207
|
}
|
193
208
|
|
194
209
|
void resume_ingest(std::string index_name,
|
@@ -196,7 +211,8 @@ class search_index_manager_impl
|
|
196
211
|
resume_ingest_search_index_handler&& handler) const
|
197
212
|
{
|
198
213
|
core_.execute(
|
199
|
-
core::operations::management::search_index_control_ingest_request{
|
214
|
+
core::operations::management::search_index_control_ingest_request{
|
215
|
+
std::move(index_name), false, bucket_name_, scope_name_, {}, options.timeout },
|
200
216
|
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp)); });
|
201
217
|
}
|
202
218
|
|
@@ -204,16 +220,20 @@ class search_index_manager_impl
|
|
204
220
|
const allow_querying_search_index_options::built& options,
|
205
221
|
allow_querying_search_index_handler&& handler) const
|
206
222
|
{
|
207
|
-
core_.execute(
|
208
|
-
|
223
|
+
core_.execute(
|
224
|
+
core::operations::management::search_index_control_query_request{
|
225
|
+
std::move(index_name), true, bucket_name_, scope_name_, {}, options.timeout },
|
226
|
+
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp)); });
|
209
227
|
}
|
210
228
|
|
211
229
|
void disallow_querying(std::string index_name,
|
212
230
|
const disallow_querying_search_index_options::built& options,
|
213
231
|
disallow_querying_search_index_handler&& handler) const
|
214
232
|
{
|
215
|
-
core_.execute(
|
216
|
-
|
233
|
+
core_.execute(
|
234
|
+
core::operations::management::search_index_control_query_request{
|
235
|
+
std::move(index_name), false, bucket_name_, scope_name_, {}, options.timeout },
|
236
|
+
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp)); });
|
217
237
|
}
|
218
238
|
|
219
239
|
void freeze_plan(std::string index_name,
|
@@ -221,7 +241,8 @@ class search_index_manager_impl
|
|
221
241
|
freeze_plan_search_index_handler&& handler) const
|
222
242
|
{
|
223
243
|
core_.execute(
|
224
|
-
core::operations::management::search_index_control_plan_freeze_request{
|
244
|
+
core::operations::management::search_index_control_plan_freeze_request{
|
245
|
+
std::move(index_name), true, bucket_name_, scope_name_, {}, options.timeout },
|
225
246
|
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp)); });
|
226
247
|
}
|
227
248
|
|
@@ -230,7 +251,8 @@ class search_index_manager_impl
|
|
230
251
|
unfreeze_plan_search_index_handler&& handler) const
|
231
252
|
{
|
232
253
|
core_.execute(
|
233
|
-
core::operations::management::search_index_control_plan_freeze_request{
|
254
|
+
core::operations::management::search_index_control_plan_freeze_request{
|
255
|
+
std::move(index_name), false, bucket_name_, scope_name_, {}, options.timeout },
|
234
256
|
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp)); });
|
235
257
|
}
|
236
258
|
|
@@ -241,12 +263,14 @@ class search_index_manager_impl
|
|
241
263
|
{
|
242
264
|
core_.execute(
|
243
265
|
core::operations::management::search_index_analyze_document_request{
|
244
|
-
std::move(index_name), std::move(document), {}, options.timeout },
|
266
|
+
std::move(index_name), std::move(document), bucket_name_, scope_name_, {}, options.timeout },
|
245
267
|
[handler = std::move(handler)](auto resp) mutable { return handler(build_context(resp), convert_analysis(resp.analysis)); });
|
246
268
|
}
|
247
269
|
|
248
270
|
private:
|
249
271
|
core::cluster core_;
|
272
|
+
std::optional<std::string> bucket_name_{};
|
273
|
+
std::optional<std::string> scope_name_{};
|
250
274
|
};
|
251
275
|
|
252
276
|
search_index_manager::search_index_manager(core::cluster core)
|
@@ -466,4 +490,223 @@ search_index_manager::analyze_document(std::string index_name,
|
|
466
490
|
});
|
467
491
|
return barrier->get_future();
|
468
492
|
}
|
493
|
+
|
494
|
+
scope_search_index_manager::scope_search_index_manager(core::cluster core, std::string bucket_name, std::string scope_name)
|
495
|
+
: impl_(std::make_shared<search_index_manager_impl>(std::move(core), std::move(bucket_name), std::move(scope_name)))
|
496
|
+
{
|
497
|
+
}
|
498
|
+
|
499
|
+
void
|
500
|
+
scope_search_index_manager::get_index(std::string index_name,
|
501
|
+
const couchbase::get_search_index_options& options,
|
502
|
+
couchbase::get_search_index_handler&& handler) const
|
503
|
+
{
|
504
|
+
return impl_->get_index(std::move(index_name), options.build(), std::move(handler));
|
505
|
+
}
|
506
|
+
|
507
|
+
auto
|
508
|
+
scope_search_index_manager::get_index(std::string index_name, const couchbase::get_search_index_options& options) const
|
509
|
+
-> std::future<std::pair<manager_error_context, management::search::index>>
|
510
|
+
{
|
511
|
+
auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, management::search::index>>>();
|
512
|
+
get_index(std::move(index_name), options, [barrier](auto ctx, auto result) mutable {
|
513
|
+
barrier->set_value(std::make_pair(std::move(ctx), std::move(result)));
|
514
|
+
});
|
515
|
+
return barrier->get_future();
|
516
|
+
}
|
517
|
+
|
518
|
+
void
|
519
|
+
scope_search_index_manager::get_all_indexes(const couchbase::get_all_search_indexes_options& options,
|
520
|
+
get_all_search_indexes_handler&& handler) const
|
521
|
+
{
|
522
|
+
return impl_->get_all_indexes(options.build(), std::move(handler));
|
523
|
+
}
|
524
|
+
|
525
|
+
auto
|
526
|
+
scope_search_index_manager::get_all_indexes(const couchbase::get_all_search_indexes_options& options) const
|
527
|
+
-> std::future<std::pair<manager_error_context, std::vector<management::search::index>>>
|
528
|
+
{
|
529
|
+
auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, std::vector<management::search::index>>>>();
|
530
|
+
get_all_indexes(options,
|
531
|
+
[barrier](auto ctx, auto result) mutable { barrier->set_value(std::make_pair(std::move(ctx), std::move(result))); });
|
532
|
+
return barrier->get_future();
|
533
|
+
}
|
534
|
+
|
535
|
+
void
|
536
|
+
scope_search_index_manager::upsert_index(const management::search::index& search_index,
|
537
|
+
const couchbase::upsert_search_index_options& options,
|
538
|
+
couchbase::upsert_search_index_handler&& handler) const
|
539
|
+
{
|
540
|
+
return impl_->upsert_index(search_index, options.build(), std::move(handler));
|
541
|
+
}
|
542
|
+
|
543
|
+
auto
|
544
|
+
scope_search_index_manager::upsert_index(const management::search::index& search_index,
|
545
|
+
const couchbase::upsert_search_index_options& options) const -> std::future<manager_error_context>
|
546
|
+
{
|
547
|
+
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
548
|
+
upsert_index(search_index, options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
|
549
|
+
return barrier->get_future();
|
550
|
+
}
|
551
|
+
|
552
|
+
void
|
553
|
+
scope_search_index_manager::drop_index(std::string index_name,
|
554
|
+
const couchbase::drop_search_index_options& options,
|
555
|
+
couchbase::drop_search_index_handler&& handler) const
|
556
|
+
{
|
557
|
+
return impl_->drop_index(std::move(index_name), options.build(), std::move(handler));
|
558
|
+
}
|
559
|
+
|
560
|
+
auto
|
561
|
+
scope_search_index_manager::drop_index(std::string index_name, const couchbase::drop_search_index_options& options) const
|
562
|
+
-> std::future<manager_error_context>
|
563
|
+
{
|
564
|
+
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
565
|
+
drop_index(std::move(index_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
|
566
|
+
return barrier->get_future();
|
567
|
+
}
|
568
|
+
|
569
|
+
void
|
570
|
+
scope_search_index_manager::get_indexed_documents_count(std::string index_name,
|
571
|
+
const couchbase::get_indexed_search_index_options& options,
|
572
|
+
couchbase::get_indexed_search_index_handler&& handler) const
|
573
|
+
{
|
574
|
+
return impl_->get_indexed_documents_count(std::move(index_name), options.build(), std::move(handler));
|
575
|
+
}
|
576
|
+
|
577
|
+
auto
|
578
|
+
scope_search_index_manager::get_indexed_documents_count(std::string index_name, const get_indexed_search_index_options& options) const
|
579
|
+
-> std::future<std::pair<manager_error_context, std::uint64_t>>
|
580
|
+
{
|
581
|
+
auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, std::uint64_t>>>();
|
582
|
+
get_indexed_documents_count(std::move(index_name), options, [barrier](auto ctx, auto result) mutable {
|
583
|
+
barrier->set_value(std::make_pair(std::move(ctx), std::move(result)));
|
584
|
+
});
|
585
|
+
return barrier->get_future();
|
586
|
+
}
|
587
|
+
|
588
|
+
void
|
589
|
+
scope_search_index_manager::pause_ingest(std::string index_name,
|
590
|
+
const couchbase::pause_ingest_search_index_options& options,
|
591
|
+
couchbase::pause_ingest_search_index_handler&& handler) const
|
592
|
+
{
|
593
|
+
return impl_->pause_ingest(std::move(index_name), options.build(), std::move(handler));
|
594
|
+
}
|
595
|
+
|
596
|
+
auto
|
597
|
+
scope_search_index_manager::pause_ingest(std::string index_name, const couchbase::pause_ingest_search_index_options& options) const
|
598
|
+
-> std::future<manager_error_context>
|
599
|
+
{
|
600
|
+
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
601
|
+
pause_ingest(std::move(index_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
|
602
|
+
return barrier->get_future();
|
603
|
+
}
|
604
|
+
|
605
|
+
void
|
606
|
+
scope_search_index_manager::resume_ingest(std::string index_name,
|
607
|
+
const couchbase::resume_ingest_search_index_options& options,
|
608
|
+
couchbase::resume_ingest_search_index_handler&& handler) const
|
609
|
+
{
|
610
|
+
return impl_->resume_ingest(std::move(index_name), options.build(), std::move(handler));
|
611
|
+
}
|
612
|
+
|
613
|
+
auto
|
614
|
+
scope_search_index_manager::resume_ingest(std::string index_name, const couchbase::resume_ingest_search_index_options& options) const
|
615
|
+
-> std::future<manager_error_context>
|
616
|
+
{
|
617
|
+
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
618
|
+
resume_ingest(std::move(index_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
|
619
|
+
return barrier->get_future();
|
620
|
+
}
|
621
|
+
|
622
|
+
void
|
623
|
+
scope_search_index_manager::allow_querying(std::string index_name,
|
624
|
+
const couchbase::allow_querying_search_index_options& options,
|
625
|
+
couchbase::allow_querying_search_index_handler&& handler) const
|
626
|
+
{
|
627
|
+
return impl_->allow_querying(std::move(index_name), options.build(), std::move(handler));
|
628
|
+
}
|
629
|
+
|
630
|
+
auto
|
631
|
+
scope_search_index_manager::allow_querying(std::string index_name, const couchbase::allow_querying_search_index_options& options) const
|
632
|
+
-> std::future<manager_error_context>
|
633
|
+
{
|
634
|
+
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
635
|
+
allow_querying(std::move(index_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
|
636
|
+
return barrier->get_future();
|
637
|
+
}
|
638
|
+
|
639
|
+
void
|
640
|
+
scope_search_index_manager::disallow_querying(std::string index_name,
|
641
|
+
const couchbase::disallow_querying_search_index_options& options,
|
642
|
+
couchbase::disallow_querying_search_index_handler&& handler) const
|
643
|
+
{
|
644
|
+
return impl_->disallow_querying(std::move(index_name), options.build(), std::move(handler));
|
645
|
+
}
|
646
|
+
|
647
|
+
auto
|
648
|
+
scope_search_index_manager::disallow_querying(std::string index_name,
|
649
|
+
const couchbase::disallow_querying_search_index_options& options) const
|
650
|
+
-> std::future<manager_error_context>
|
651
|
+
{
|
652
|
+
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
653
|
+
disallow_querying(std::move(index_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
|
654
|
+
return barrier->get_future();
|
655
|
+
}
|
656
|
+
|
657
|
+
void
|
658
|
+
scope_search_index_manager::freeze_plan(std::string index_name,
|
659
|
+
const couchbase::freeze_plan_search_index_options& options,
|
660
|
+
couchbase::freeze_plan_search_index_handler&& handler) const
|
661
|
+
{
|
662
|
+
return impl_->freeze_plan(std::move(index_name), options.build(), std::move(handler));
|
663
|
+
}
|
664
|
+
|
665
|
+
auto
|
666
|
+
scope_search_index_manager::freeze_plan(std::string index_name, const couchbase::freeze_plan_search_index_options& options) const
|
667
|
+
-> std::future<manager_error_context>
|
668
|
+
{
|
669
|
+
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
670
|
+
freeze_plan(std::move(index_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
|
671
|
+
return barrier->get_future();
|
672
|
+
}
|
673
|
+
|
674
|
+
void
|
675
|
+
scope_search_index_manager::unfreeze_plan(std::string index_name,
|
676
|
+
const couchbase::unfreeze_plan_search_index_options& options,
|
677
|
+
couchbase::unfreeze_plan_search_index_handler&& handler) const
|
678
|
+
{
|
679
|
+
return impl_->unfreeze_plan(std::move(index_name), options.build(), std::move(handler));
|
680
|
+
}
|
681
|
+
|
682
|
+
auto
|
683
|
+
scope_search_index_manager::unfreeze_plan(std::string index_name, const couchbase::unfreeze_plan_search_index_options& options) const
|
684
|
+
-> std::future<manager_error_context>
|
685
|
+
{
|
686
|
+
auto barrier = std::make_shared<std::promise<manager_error_context>>();
|
687
|
+
unfreeze_plan(std::move(index_name), options, [barrier](auto ctx) mutable { barrier->set_value(std::move(ctx)); });
|
688
|
+
return barrier->get_future();
|
689
|
+
}
|
690
|
+
|
691
|
+
void
|
692
|
+
scope_search_index_manager::analyze_document(std::string index_name,
|
693
|
+
std::string document,
|
694
|
+
const couchbase::analyze_document_options& options,
|
695
|
+
couchbase::analyze_document_handler&& handler) const
|
696
|
+
{
|
697
|
+
return impl_->analyze_document(std::move(index_name), std::move(document), options.build(), std::move(handler));
|
698
|
+
}
|
699
|
+
|
700
|
+
auto
|
701
|
+
scope_search_index_manager::analyze_document(std::string index_name,
|
702
|
+
std::string document,
|
703
|
+
const couchbase::analyze_document_options& options) const
|
704
|
+
-> std::future<std::pair<manager_error_context, std::vector<std::string>>>
|
705
|
+
{
|
706
|
+
auto barrier = std::make_shared<std::promise<std::pair<manager_error_context, std::vector<std::string>>>>();
|
707
|
+
analyze_document(std::move(index_name), std::move(document), options, [barrier](auto ctx, auto result) mutable {
|
708
|
+
barrier->set_value(std::make_pair(std::move(ctx), std::move(result)));
|
709
|
+
});
|
710
|
+
return barrier->get_future();
|
711
|
+
}
|
469
712
|
} // namespace couchbase
|
@@ -0,0 +1,139 @@
|
|
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 "core/impl/encoded_search_query.hxx"
|
19
|
+
|
20
|
+
#include <couchbase/search_request.hxx>
|
21
|
+
|
22
|
+
namespace couchbase
|
23
|
+
{
|
24
|
+
class search_request_impl
|
25
|
+
{
|
26
|
+
public:
|
27
|
+
explicit search_request_impl(std::optional<encoded_search_query> search_query,
|
28
|
+
std::optional<encoded_search_query> vector_search,
|
29
|
+
std::optional<vector_search_options::built> options)
|
30
|
+
: search_query_(std::move(search_query))
|
31
|
+
, vector_search_(std::move(vector_search))
|
32
|
+
, vector_search_options_(std::move(options))
|
33
|
+
{
|
34
|
+
}
|
35
|
+
|
36
|
+
static search_request_impl create(const search_query& query)
|
37
|
+
{
|
38
|
+
auto encoded = query.encode();
|
39
|
+
if (encoded.ec) {
|
40
|
+
throw std::system_error(encoded.ec, "unable to encode the search_query");
|
41
|
+
}
|
42
|
+
return search_request_impl(encoded, {}, {});
|
43
|
+
}
|
44
|
+
|
45
|
+
static search_request_impl create(const vector_search& search)
|
46
|
+
{
|
47
|
+
auto encoded = search.encode();
|
48
|
+
if (encoded.ec) {
|
49
|
+
throw std::system_error(encoded.ec, "unable to encode the vector_search");
|
50
|
+
}
|
51
|
+
return search_request_impl({}, encoded, search.options());
|
52
|
+
}
|
53
|
+
|
54
|
+
void search_query(const couchbase::search_query& query)
|
55
|
+
{
|
56
|
+
search_query_ = query.encode();
|
57
|
+
if (search_query_.value().ec) {
|
58
|
+
throw std::system_error(search_query_.value().ec, "unable to encode the search_query");
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
void vector_search(const couchbase::vector_search& search)
|
63
|
+
{
|
64
|
+
vector_search_ = search.encode();
|
65
|
+
if (vector_search_.value().ec) {
|
66
|
+
throw std::system_error(vector_search_.value().ec, "unable to encode the vector_search");
|
67
|
+
}
|
68
|
+
vector_search_options_ = search.options();
|
69
|
+
}
|
70
|
+
|
71
|
+
[[nodiscard]] std::optional<encoded_search_query> search_query() const
|
72
|
+
{
|
73
|
+
return search_query_;
|
74
|
+
}
|
75
|
+
|
76
|
+
[[nodiscard]] std::optional<encoded_search_query> vector_search() const
|
77
|
+
{
|
78
|
+
return vector_search_;
|
79
|
+
}
|
80
|
+
|
81
|
+
[[nodiscard]] std::optional<vector_search_options::built> vector_options() const
|
82
|
+
{
|
83
|
+
return vector_search_options_;
|
84
|
+
}
|
85
|
+
|
86
|
+
private:
|
87
|
+
std::optional<encoded_search_query> search_query_;
|
88
|
+
std::optional<encoded_search_query> vector_search_;
|
89
|
+
std::optional<vector_search_options::built> vector_search_options_;
|
90
|
+
};
|
91
|
+
|
92
|
+
search_request::search_request(const couchbase::search_query& query)
|
93
|
+
: impl_{ std::make_shared<search_request_impl>(search_request_impl::create(query)) }
|
94
|
+
{
|
95
|
+
}
|
96
|
+
|
97
|
+
search_request::search_request(const couchbase::vector_search& search)
|
98
|
+
: impl_{ std::make_shared<search_request_impl>(search_request_impl::create(search)) }
|
99
|
+
{
|
100
|
+
}
|
101
|
+
|
102
|
+
auto
|
103
|
+
search_request::search_query(const couchbase::search_query& search_query) -> search_request&
|
104
|
+
{
|
105
|
+
if (impl_->search_query().has_value()) {
|
106
|
+
throw std::invalid_argument("There can only be one search_query in a search request");
|
107
|
+
}
|
108
|
+
impl_->search_query(search_query);
|
109
|
+
return *this;
|
110
|
+
}
|
111
|
+
|
112
|
+
auto
|
113
|
+
search_request::vector_search(const couchbase::vector_search& vector_search) -> search_request&
|
114
|
+
{
|
115
|
+
if (impl_->vector_search().has_value()) {
|
116
|
+
throw std::invalid_argument("There can only be one vector_search in a search request");
|
117
|
+
}
|
118
|
+
impl_->vector_search(vector_search);
|
119
|
+
return *this;
|
120
|
+
}
|
121
|
+
|
122
|
+
[[nodiscard]] std::optional<encoded_search_query>
|
123
|
+
search_request::search_query() const
|
124
|
+
{
|
125
|
+
return impl_->search_query();
|
126
|
+
}
|
127
|
+
|
128
|
+
[[nodiscard]] std::optional<encoded_search_query>
|
129
|
+
search_request::vector_search() const
|
130
|
+
{
|
131
|
+
return impl_->vector_search();
|
132
|
+
}
|
133
|
+
|
134
|
+
[[nodiscard]] std::optional<couchbase::vector_search_options::built>
|
135
|
+
search_request::vector_options()
|
136
|
+
{
|
137
|
+
return impl_->vector_options();
|
138
|
+
}
|
139
|
+
} // namespace couchbase
|
@@ -0,0 +1,42 @@
|
|
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 "encoded_search_query.hxx"
|
19
|
+
|
20
|
+
#include <couchbase/vector_query.hxx>
|
21
|
+
|
22
|
+
namespace couchbase
|
23
|
+
{
|
24
|
+
auto
|
25
|
+
vector_query::encode() const -> encoded_search_query
|
26
|
+
{
|
27
|
+
encoded_search_query built;
|
28
|
+
built.query = tao::json::empty_object;
|
29
|
+
if (boost_) {
|
30
|
+
built.query["boost"] = boost_.value();
|
31
|
+
}
|
32
|
+
built.query["field"] = vector_field_name_;
|
33
|
+
|
34
|
+
tao::json::value vector_values = tao::json::empty_array;
|
35
|
+
for (const auto value : vector_query_) {
|
36
|
+
vector_values.push_back(value);
|
37
|
+
}
|
38
|
+
built.query["vector"] = vector_values;
|
39
|
+
built.query["k"] = num_candidates_;
|
40
|
+
return built;
|
41
|
+
}
|
42
|
+
} // namespace couchbase
|
@@ -0,0 +1,40 @@
|
|
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 "encoded_search_query.hxx"
|
19
|
+
|
20
|
+
#include <couchbase/vector_search.hxx>
|
21
|
+
|
22
|
+
namespace couchbase
|
23
|
+
{
|
24
|
+
auto
|
25
|
+
vector_search::encode() const -> encoded_search_query
|
26
|
+
{
|
27
|
+
encoded_search_query built;
|
28
|
+
|
29
|
+
built.query = tao::json::empty_array;
|
30
|
+
|
31
|
+
for (const auto& query : vector_queries_) {
|
32
|
+
auto encoded = query.encode();
|
33
|
+
if (encoded.ec) {
|
34
|
+
return { encoded.ec };
|
35
|
+
}
|
36
|
+
built.query.push_back(encoded.query);
|
37
|
+
}
|
38
|
+
return built;
|
39
|
+
}
|
40
|
+
} // namespace couchbase
|
@@ -370,11 +370,12 @@ class http_session : public std::enable_shared_from_this<http_session>
|
|
370
370
|
return;
|
371
371
|
}
|
372
372
|
if (ec) {
|
373
|
-
CB_LOG_ERROR("{} error on resolve: {}", info_.log_prefix(), ec.message());
|
373
|
+
CB_LOG_ERROR("{} error on resolve \"{}:{}\": {}", info_.log_prefix(), hostname_, service_, ec.message());
|
374
374
|
return;
|
375
375
|
}
|
376
376
|
last_active_ = std::chrono::steady_clock::now();
|
377
377
|
endpoints_ = endpoints;
|
378
|
+
CB_LOG_TRACE("{} resolved \"{}:{}\" to {} endpoint(s)", info_.log_prefix(), hostname_, service_, endpoints_.size());
|
378
379
|
do_connect(endpoints_.begin());
|
379
380
|
deadline_timer_.async_wait(std::bind(&http_session::check_deadline, shared_from_this(), std::placeholders::_1));
|
380
381
|
}
|
@@ -385,15 +386,17 @@ class http_session : public std::enable_shared_from_this<http_session>
|
|
385
386
|
return;
|
386
387
|
}
|
387
388
|
if (it != endpoints_.end()) {
|
388
|
-
CB_LOG_DEBUG("{} connecting to {}:{}, timeout={}ms",
|
389
|
+
CB_LOG_DEBUG("{} connecting to {}:{} (\"{}:{}\"), timeout={}ms",
|
389
390
|
info_.log_prefix(),
|
390
391
|
it->endpoint().address().to_string(),
|
391
392
|
it->endpoint().port(),
|
393
|
+
hostname_,
|
394
|
+
service_,
|
392
395
|
http_ctx_.options.connect_timeout.count());
|
393
396
|
deadline_timer_.expires_after(http_ctx_.options.connect_timeout);
|
394
397
|
stream_->async_connect(it->endpoint(), std::bind(&http_session::on_connect, shared_from_this(), std::placeholders::_1, it));
|
395
398
|
} else {
|
396
|
-
CB_LOG_ERROR("{} no more endpoints left to connect", info_.log_prefix());
|
399
|
+
CB_LOG_ERROR("{} no more endpoints left to connect, \"{}:{}\" is not reachable", info_.log_prefix(), hostname_, service_);
|
397
400
|
stop();
|
398
401
|
}
|
399
402
|
}
|
@@ -58,6 +58,12 @@ class http_session_manager
|
|
58
58
|
meter_ = std::move(meter);
|
59
59
|
}
|
60
60
|
|
61
|
+
auto configuration_capabilities() const -> configuration_capabilities
|
62
|
+
{
|
63
|
+
std::scoped_lock config_lock(config_mutex_);
|
64
|
+
return config_.capabilities;
|
65
|
+
}
|
66
|
+
|
61
67
|
void update_config(topology::configuration config) override
|
62
68
|
{
|
63
69
|
std::scoped_lock config_lock(config_mutex_, sessions_mutex_);
|
@@ -387,7 +393,7 @@ class http_session_manager
|
|
387
393
|
cluster_options options_{};
|
388
394
|
|
389
395
|
topology::configuration config_{};
|
390
|
-
std::mutex config_mutex_{};
|
396
|
+
mutable std::mutex config_mutex_{};
|
391
397
|
std::map<service_type, std::list<std::shared_ptr<http_session>>> busy_sessions_{};
|
392
398
|
std::map<service_type, std::list<std::shared_ptr<http_session>>> idle_sessions_{};
|
393
399
|
std::size_t next_index_{ 0 };
|
@@ -289,6 +289,16 @@ struct mcbp_command : public std::enable_shared_from_this<mcbp_command<Manager,
|
|
289
289
|
if (status == key_value_status_code::unknown_collection) {
|
290
290
|
return self->handle_unknown_collection();
|
291
291
|
}
|
292
|
+
if (status == key_value_status_code::config_only) {
|
293
|
+
CB_LOG_DEBUG(
|
294
|
+
"{} server returned status 0x{:02x} ({}) meaning that the node does not serve data operations, requesting new "
|
295
|
+
"configuration and retrying",
|
296
|
+
self->session_->log_prefix(),
|
297
|
+
msg.header.status(),
|
298
|
+
status);
|
299
|
+
self->manager_->fetch_config();
|
300
|
+
return io::retry_orchestrator::maybe_retry(self->manager_, self, retry_reason::service_response_code_indicated, ec);
|
301
|
+
}
|
292
302
|
if (error_code && error_code.value().has_retry_attribute()) {
|
293
303
|
reason = retry_reason::key_value_error_map_retry_indicated;
|
294
304
|
} else {
|