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,291 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2020-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/allow_querying_search_index_options.hxx>
21
+ #include <couchbase/analyze_document_options.hxx>
22
+ #include <couchbase/disallow_querying_search_index_options.hxx>
23
+ #include <couchbase/drop_search_index_options.hxx>
24
+ #include <couchbase/freeze_plan_search_index_options.hxx>
25
+ #include <couchbase/get_all_search_indexes_options.hxx>
26
+ #include <couchbase/get_indexed_search_index_options.hxx>
27
+ #include <couchbase/get_search_index_options.hxx>
28
+ #include <couchbase/pause_ingest_search_index_options.hxx>
29
+ #include <couchbase/resume_ingest_search_index_options.hxx>
30
+ #include <couchbase/unfreeze_plan_search_index_options.hxx>
31
+ #include <couchbase/upsert_search_index_options.hxx>
32
+
33
+ #include <future>
34
+
35
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
36
+ namespace couchbase
37
+ {
38
+ namespace core
39
+ {
40
+ class cluster;
41
+ } // namespace core
42
+ class search_index_manager_impl;
43
+ } // namespace couchbase
44
+ #endif
45
+
46
+ namespace couchbase
47
+ {
48
+ class scope;
49
+
50
+ class scope_search_index_manager
51
+ {
52
+ public:
53
+ /**
54
+ * Fetches a scope-level index from the server if it exists
55
+ *
56
+ * @param index_name the name of the index
57
+ * @param options optional parameters
58
+ * @param handler handler that implements @ref get_search_index_handler
59
+ *
60
+ * @since 1.0.0
61
+ * @volatile
62
+ */
63
+ void get_index(std::string index_name, const get_search_index_options& options, get_search_index_handler&& handler) const;
64
+
65
+ [[nodiscard]] auto get_index(std::string index_name, const get_search_index_options& options = {}) const
66
+ -> std::future<std::pair<manager_error_context, management::search::index>>;
67
+
68
+ /**
69
+ * Fetches all scope-level indexes from the server
70
+ *
71
+ * @param options optional parameters
72
+ * @param handler handler that implements @ref get_all_search_indexes_handler
73
+ *
74
+ * @since 1.0.0
75
+ * @volatile
76
+ */
77
+ void get_all_indexes(const get_all_search_indexes_options& options, get_all_search_indexes_handler&& handler) const;
78
+
79
+ [[nodiscard]] auto get_all_indexes(const get_all_search_indexes_options& options = {}) const
80
+ -> std::future<std::pair<manager_error_context, std::vector<management::search::index>>>;
81
+
82
+ /**
83
+ * Creates, or updates a scope-level index
84
+ *
85
+ * @param search_index the index definition including name and settings
86
+ * @param options optional parameters
87
+ * @param handler handler that implements @ref upsert_search_index_handler
88
+ *
89
+ * @since 1.0.0
90
+ * @volatile
91
+ */
92
+ void upsert_index(const management::search::index& search_index,
93
+ const upsert_search_index_options& options,
94
+ upsert_search_index_handler&& handler) const;
95
+
96
+ [[nodiscard]] auto upsert_index(const management::search::index& search_index, const upsert_search_index_options& options = {}) const
97
+ -> std::future<manager_error_context>;
98
+
99
+ /**
100
+ * Drops a scope-level index
101
+ *
102
+ * @param index_name the name of the search index
103
+ * @param options optional parameters
104
+ * @param handler handler that implements @ref drop_search_index_handler
105
+ *
106
+ * @since 1.0.0
107
+ * @volatile
108
+ */
109
+ void drop_index(std::string index_name, const drop_search_index_options& options, drop_search_index_handler&& handler) const;
110
+
111
+ [[nodiscard]] auto drop_index(std::string index_name, const drop_search_index_options& options = {}) const
112
+ -> std::future<manager_error_context>;
113
+
114
+ /**
115
+ * Retrieves the number of documents that have been indexed for a scope-level index
116
+ *
117
+ * @param index_name the name of the search index
118
+ * @param options optional parameters
119
+ * @param handler handler that implements @ref get_indexed_search_index_handler
120
+ *
121
+ * @since 1.0.0
122
+ * @volatile
123
+ */
124
+ void get_indexed_documents_count(std::string index_name,
125
+ const get_indexed_search_index_options& options,
126
+ get_indexed_search_index_handler&& handler) const;
127
+
128
+ [[nodiscard]] auto get_indexed_documents_count(std::string index_name, const get_indexed_search_index_options& options = {}) const
129
+ -> std::future<std::pair<manager_error_context, std::uint64_t>>;
130
+
131
+ /**
132
+ * Pauses updates and maintenance for a scope-level index.
133
+ *
134
+ * @param index_name the name of the search index
135
+ * @param options optional parameters
136
+ * @param handler handler that implements @ref pause_ingest_search_index_handler
137
+ *
138
+ * @since 1.0.0
139
+ * @volatile
140
+ */
141
+ void pause_ingest(std::string index_name,
142
+ const pause_ingest_search_index_options& options,
143
+ pause_ingest_search_index_handler&& handler) const;
144
+
145
+ [[nodiscard]] auto pause_ingest(std::string index_name, const pause_ingest_search_index_options& options = {}) const
146
+ -> std::future<manager_error_context>;
147
+
148
+ /**
149
+ * Resumes updates and maintenance for a scope-level index.
150
+ *
151
+ * @param index_name the name of the search index
152
+ * @param options optional parameters
153
+ * @param handler handler that implements @ref resume_ingest_search_index_handler
154
+ *
155
+ * @since 1.0.0
156
+ * @volatile
157
+ */
158
+ void resume_ingest(std::string index_name,
159
+ const resume_ingest_search_index_options& options,
160
+ resume_ingest_search_index_handler&& handler) const;
161
+
162
+ [[nodiscard]] auto resume_ingest(std::string index_name, const resume_ingest_search_index_options& options = {}) const
163
+ -> std::future<manager_error_context>;
164
+
165
+ /**
166
+ * Allows querying against a scope-level index
167
+ *
168
+ * @param index_name the name of the search index
169
+ * @param options optional parameters
170
+ * @param handler handler that implements @ref allow_querying_search_index_handler
171
+ *
172
+ * @since 1.0.0
173
+ * @volatile
174
+ */
175
+ void allow_querying(std::string index_name,
176
+ const allow_querying_search_index_options& options,
177
+ allow_querying_search_index_handler&& handler) const;
178
+
179
+ [[nodiscard]] auto allow_querying(std::string index_name, const allow_querying_search_index_options& options = {}) const
180
+ -> std::future<manager_error_context>;
181
+
182
+ /**
183
+ * Disallows querying against a scope-level index
184
+ *
185
+ * @param index_name the name of the search index
186
+ * @param options optional parameters
187
+ * @param handler handler that implements @ref disallow_querying_search_index_handler
188
+ *
189
+ * @since 1.0.0
190
+ * @volatile
191
+ */
192
+ void disallow_querying(std::string index_name,
193
+ const disallow_querying_search_index_options& options,
194
+ disallow_querying_search_index_handler&& handler) const;
195
+
196
+ [[nodiscard]] auto disallow_querying(std::string index_name, const disallow_querying_search_index_options& options = {}) const
197
+ -> std::future<manager_error_context>;
198
+
199
+ /**
200
+ * Freeze the assignment of scope-level index partitions to nodes.
201
+ *
202
+ * @param index_name the name of the search index
203
+ * @param options optional parameters
204
+ * @param handler handler that implements @ref freeze_plan_search_index_handler
205
+ *
206
+ * @since 1.0.0
207
+ * @volatile
208
+ */
209
+ void freeze_plan(std::string index_name,
210
+ const freeze_plan_search_index_options& options,
211
+ freeze_plan_search_index_handler&& handler) const;
212
+
213
+ [[nodiscard]] auto freeze_plan(std::string index_name, const freeze_plan_search_index_options& options = {}) const
214
+ -> std::future<manager_error_context>;
215
+
216
+ /**
217
+ * Unfreeze the assignment of scope-level index partitions to nodes.
218
+ *
219
+ * @param index_name the name of the search index
220
+ * @param options optional parameters
221
+ * @param handler handler that implements @ref unfreeze_plan_search_index_handler
222
+ *
223
+ * @since 1.0.0
224
+ * @volatile
225
+ */
226
+ void unfreeze_plan(std::string index_name,
227
+ const unfreeze_plan_search_index_options& options,
228
+ unfreeze_plan_search_index_handler&& handler) const;
229
+
230
+ [[nodiscard]] auto unfreeze_plan(std::string index_name, const unfreeze_plan_search_index_options& options = {}) const
231
+ -> std::future<manager_error_context>;
232
+
233
+ /**
234
+ * Allows to see how a document is analyzed against a specific scope-level index.
235
+ *
236
+ * @param index_name the name of the search index
237
+ * @param document the document to be analyzed
238
+ * @param options optional parameters
239
+ * @param handler handler that implements @ref analyze_document_handler
240
+ *
241
+ * @since 1.0.0
242
+ * @volatile
243
+ */
244
+ template<typename Document>
245
+ void analyze_document(std::string index_name,
246
+ Document document,
247
+ const analyze_document_options& options,
248
+ analyze_document_handler&& handler) const
249
+ {
250
+ auto encoded = couchbase::codec::default_json_transcoder::encode(document); // Encode as JSON and convert to string
251
+ auto decoded = std::string{ reinterpret_cast<const char*>(encoded.data.data()), encoded.data.size() };
252
+ return analyze_document(std::move(index_name), decoded, options, std::move(handler));
253
+ }
254
+
255
+ template<typename Document>
256
+ [[nodiscard]] auto analyze_document(std::string index_name, Document document, const analyze_document_options& options = {}) const
257
+ -> std::future<std::pair<manager_error_context, std::vector<std::string>>>
258
+ {
259
+ auto encoded = couchbase::codec::default_json_transcoder::encode(document); // Encode as JSON and convert to string
260
+ auto decoded = std::string{ reinterpret_cast<const char*>(encoded.data.data()), encoded.data.size() };
261
+
262
+ return analyze_document(std::move(index_name), decoded, options);
263
+ }
264
+
265
+ /**
266
+ * Allows to see how a document is analyzed against a specific scope-level index.
267
+ *
268
+ * @param index_name the name of the search index
269
+ * @param document the document to be analyzed encoded in JSON
270
+ * @param options optional parameters
271
+ * @param handler handler that implements @ref analyze_document_handler
272
+ *
273
+ * @since 1.0.0
274
+ * @volatile
275
+ */
276
+ void analyze_document(std::string index_name,
277
+ std::string document,
278
+ const analyze_document_options& options,
279
+ analyze_document_handler&& handler) const;
280
+
281
+ [[nodiscard]] auto analyze_document(std::string index_name, std::string document, const analyze_document_options& options) const
282
+ -> std::future<std::pair<manager_error_context, std::vector<std::string>>>;
283
+
284
+ private:
285
+ friend class scope;
286
+
287
+ explicit scope_search_index_manager(core::cluster core, std::string bucket_name, std::string scope_name);
288
+
289
+ std::shared_ptr<search_index_manager_impl> impl_;
290
+ };
291
+ } // namespace couchbase
@@ -0,0 +1,120 @@
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/search_query.hxx>
21
+ #include <couchbase/vector_search.hxx>
22
+
23
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
24
+ namespace couchbase
25
+ {
26
+ namespace core
27
+ {
28
+ class cluster;
29
+ } // namespace core
30
+ class search_request_impl;
31
+ } // namespace couchbase
32
+ #endif
33
+
34
+ namespace couchbase
35
+ {
36
+ /**
37
+ * A search_request is used to perform operations against the Full Text Search (FTS) Couchbase service.
38
+ *
39
+ * It can be used to send an FTS @ref search_query, and/or a @ref vector_search
40
+ *
41
+ * @since 1.0.0
42
+ * @volatile
43
+ */
44
+ class search_request
45
+ {
46
+ public:
47
+ /**
48
+ * Create a new search_request with a @ref search_query
49
+ *
50
+ * @param search_query the query to run
51
+ *
52
+ * @since 1.0.0
53
+ * @volatile
54
+ */
55
+ explicit search_request(const couchbase::search_query& search_query);
56
+
57
+ /**
58
+ * Create a new search_request with a @ref vector_search
59
+ *
60
+ * @param vector_search the vector_search to run
61
+ *
62
+ * @since 1.0.0
63
+ * @volatile
64
+ */
65
+ explicit search_request(const couchbase::vector_search& vector_search);
66
+
67
+ /**
68
+ * Used to run a @ref search_query together with an existing @ref vector_search.
69
+ * Note that a maximum of one SearchQuery and one VectorSearch can be provided.
70
+ *
71
+ * @param search_query the search_query to run with an existing vector_search.
72
+ *
73
+ * @return this search_request for chaining purposes.
74
+ *
75
+ * @since 1.0.0
76
+ * @volatile
77
+ */
78
+ auto search_query(const couchbase::search_query& search_query) -> search_request&;
79
+
80
+ /**
81
+ * Used to run a @ref vector_query together with an existing @ref search_query.
82
+ * Note that a maximum of one SearchQuery and one VectorSearch can be provided.
83
+ *
84
+ * @param vector_search the vector_search to be run with an existing search_query.
85
+ *
86
+ * @return this search_request for chaining purposes.
87
+ *
88
+ * @since 1.0.0
89
+ * @volatile
90
+ */
91
+ auto vector_search(const couchbase::vector_search& vector_search) -> search_request&;
92
+
93
+ /**
94
+ * @return encoded representation of the query.
95
+ *
96
+ * @since 1.0.0
97
+ * @internal
98
+ */
99
+ [[nodiscard]] std::optional<encoded_search_query> search_query() const;
100
+
101
+ /**
102
+ * @return encoded representation of the vector search query.
103
+ *
104
+ * @since 1.0.0
105
+ * @internal
106
+ */
107
+ [[nodiscard]] std::optional<encoded_search_query> vector_search() const;
108
+
109
+ /**
110
+ * @return vector_search_options, if set
111
+ *
112
+ * @since 1.0.0
113
+ * @internal
114
+ */
115
+ [[nodiscard]] std::optional<vector_search_options::built> vector_options();
116
+
117
+ private:
118
+ std::shared_ptr<search_request_impl> impl_;
119
+ };
120
+ } // namespace couchbase
@@ -0,0 +1,58 @@
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
+ namespace couchbase
21
+ {
22
+ enum class service_type {
23
+ /**
24
+ * The Key-Value service (KV)
25
+ */
26
+ key_value,
27
+
28
+ /**
29
+ * The Query service (SQL++)
30
+ */
31
+ query,
32
+
33
+ /**
34
+ * The Analytics service
35
+ */
36
+ analytics,
37
+
38
+ /**
39
+ * The Search service (FTS)
40
+ */
41
+ search,
42
+
43
+ /**
44
+ * The View service
45
+ */
46
+ view,
47
+
48
+ /**
49
+ * The Cluster Manager service (ns_server)
50
+ */
51
+ management,
52
+
53
+ /**
54
+ * The Eventing service
55
+ */
56
+ eventing,
57
+ };
58
+ } // namespace couchbase
@@ -17,26 +17,55 @@
17
17
 
18
18
  #pragma once
19
19
 
20
- #include <functional>
20
+ #include <couchbase/common_options.hxx>
21
+ #include <couchbase/manager_error_context.hxx>
22
+
23
+ #include <cstdint>
21
24
  #include <memory>
22
25
  #include <optional>
23
- #include <string>
24
26
 
25
27
  namespace couchbase
26
28
  {
27
29
  struct update_collection_options : public common_options<update_collection_options> {
28
30
  public:
31
+ /**
32
+ * Immutable value object representing consistent options.
33
+ *
34
+ * @since 1.0.0
35
+ * @internal
36
+ */
29
37
  struct built : public common_options<update_collection_options>::built {
30
38
  };
31
39
 
40
+ /**
41
+ * Validates the options and returns them as an immutable value.
42
+ *
43
+ * @return consistent options as an immutable value
44
+ *
45
+ * @exception std::system_error with code errc::common::invalid_argument if the options are not valid
46
+ *
47
+ * @since 1.0.0
48
+ * @internal
49
+ */
32
50
  [[nodiscard]] auto build() const -> built
33
51
  {
34
52
  return { build_common_options() };
35
53
  }
36
54
  };
37
55
 
56
+ /**
57
+ * The settings that should be updated for the collection
58
+ */
38
59
  struct update_collection_settings {
39
- std::optional<std::uint32_t> max_expiry{};
60
+ /**
61
+ * The maximum expiry, in seconds, for documents in this collection. Values greater than or equal to -1 are valid.
62
+ * Value of 0 sets max_expiry to the bucket-level setting and value of -1 to set it as no-expiry.
63
+ */
64
+ std::optional<std::int32_t> max_expiry{};
65
+
66
+ /**
67
+ * Whether history retention should be enabled.
68
+ */
40
69
  std::optional<bool> history{};
41
70
  };
42
71
 
@@ -0,0 +1,99 @@
1
+ #include <utility>
2
+
3
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
4
+ /*
5
+ * Copyright 2023-Present Couchbase, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #pragma once
21
+
22
+ namespace couchbase
23
+ {
24
+ /**
25
+ * @since 1.0.0
26
+ * @volatile
27
+ */
28
+ class vector_query
29
+ {
30
+ public:
31
+ /**
32
+ * Creates a vector query
33
+ *
34
+ * @param vector_field_name the document field that contains the vector
35
+ * @param vector_query the vector query to run. Cannot be empty.
36
+ *
37
+ * @since 1.0.0
38
+ * @volatile
39
+ */
40
+ vector_query(std::string vector_field_name, std::vector<double> vector_query)
41
+ : vector_field_name_{ std::move(vector_field_name) }
42
+ , vector_query_{ std::move(vector_query) }
43
+ {
44
+ if (vector_query_.empty()) {
45
+ throw std::invalid_argument("the vector_query cannot be empty");
46
+ }
47
+ }
48
+
49
+ /**
50
+ * The number of results that will be returned from this vector query. Defaults to 3.
51
+ *
52
+ * @param num_candidates the number of results returned
53
+ *
54
+ * @return this vector_query for chaining purposes
55
+ *
56
+ * @since 1.0.0
57
+ * @volatile
58
+ */
59
+ auto num_candidates(std::uint32_t num_candidates) -> vector_query&
60
+ {
61
+ if (num_candidates < 1) {
62
+ throw std::invalid_argument("The num_candidates cannot be less than 1");
63
+ }
64
+ num_candidates_ = num_candidates;
65
+ return *this;
66
+ }
67
+
68
+ /**
69
+ * The boost parameter is used to increase the relative weight of a clause (with a boost greater than 1) or decrease the relative weight
70
+ * (with a boost between 0 and 1).
71
+ *
72
+ * @param boost boost value
73
+ *
74
+ * @return this vector_query for chaining purposes.
75
+ *
76
+ * @since 1.0.0
77
+ * @volatile
78
+ */
79
+ auto boost(double boost) -> vector_query&
80
+ {
81
+ boost_ = boost;
82
+ return *this;
83
+ }
84
+
85
+ /**
86
+ * @return encoded representation of the query.
87
+ *
88
+ * @since 1.0.0
89
+ * @internal
90
+ */
91
+ [[nodiscard]] auto encode() const -> encoded_search_query;
92
+
93
+ private:
94
+ std::string vector_field_name_;
95
+ std::vector<double> vector_query_;
96
+ std::uint32_t num_candidates_{ 3 };
97
+ std::optional<double> boost_{};
98
+ };
99
+ } // namespace couchbase