couchbase 4.2.3 → 4.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. package/deps/couchbase-cxx-client/CMakeLists.txt +54 -4
  2. package/deps/couchbase-cxx-client/README.md +1 -0
  3. package/deps/couchbase-cxx-client/bin/create-search-index +164 -0
  4. package/deps/couchbase-cxx-client/bin/init-cluster +55 -10
  5. package/deps/couchbase-cxx-client/bin/run-unit-tests +62 -6
  6. package/deps/couchbase-cxx-client/bin/travel-sample-index-v6.json +184 -0
  7. package/deps/couchbase-cxx-client/bin/travel-sample-index.json +188 -0
  8. package/deps/couchbase-cxx-client/cmake/Documentation.cmake +0 -1
  9. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +98 -3
  10. package/deps/couchbase-cxx-client/cmake/Testing.cmake +8 -0
  11. package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +3 -0
  12. package/deps/couchbase-cxx-client/core/bucket.cxx +183 -152
  13. package/deps/couchbase-cxx-client/core/bucket.hxx +17 -4
  14. package/deps/couchbase-cxx-client/core/cluster.hxx +18 -1
  15. package/deps/couchbase-cxx-client/core/cluster_options.hxx +1 -0
  16. package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +2 -1
  17. package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +10 -12
  18. package/deps/couchbase-cxx-client/core/error_context/search.hxx +1 -1
  19. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
  20. package/deps/couchbase-cxx-client/core/impl/boolean_field_query.cxx +40 -0
  21. package/deps/couchbase-cxx-client/core/impl/boolean_query.cxx +62 -0
  22. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -0
  23. package/deps/couchbase-cxx-client/core/impl/conjunction_query.cxx +51 -0
  24. package/deps/couchbase-cxx-client/core/impl/date_range.cxx +89 -0
  25. package/deps/couchbase-cxx-client/core/impl/date_range_facet.cxx +54 -0
  26. package/deps/couchbase-cxx-client/core/impl/date_range_facet_result.cxx +64 -0
  27. package/deps/couchbase-cxx-client/core/impl/date_range_query.cxx +125 -0
  28. package/deps/couchbase-cxx-client/core/impl/disjunction_query.cxx +51 -0
  29. package/deps/couchbase-cxx-client/core/impl/encoded_search_facet.hxx +29 -0
  30. package/deps/couchbase-cxx-client/core/impl/encoded_search_query.hxx +29 -0
  31. package/deps/couchbase-cxx-client/core/impl/encoded_search_sort.hxx +29 -0
  32. package/deps/couchbase-cxx-client/core/impl/geo_bounding_box_query.cxx +46 -0
  33. package/deps/couchbase-cxx-client/core/impl/geo_distance_query.cxx +43 -0
  34. package/deps/couchbase-cxx-client/core/impl/geo_polygon_query.cxx +46 -0
  35. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.cxx +80 -0
  36. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.hxx +48 -0
  37. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.cxx +80 -0
  38. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.hxx +48 -0
  39. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.cxx +141 -0
  40. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.hxx +61 -0
  41. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.cxx +60 -0
  42. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.hxx +41 -0
  43. package/deps/couchbase-cxx-client/core/impl/internal_search_result.cxx +84 -0
  44. package/deps/couchbase-cxx-client/core/impl/internal_search_result.hxx +43 -0
  45. package/deps/couchbase-cxx-client/core/impl/internal_search_row.cxx +82 -0
  46. package/deps/couchbase-cxx-client/core/impl/internal_search_row.hxx +56 -0
  47. package/deps/couchbase-cxx-client/core/impl/internal_search_row_location.hxx +32 -0
  48. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.cxx +137 -0
  49. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.hxx +45 -0
  50. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.cxx +80 -0
  51. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.hxx +48 -0
  52. package/deps/couchbase-cxx-client/core/impl/key_value_error_context.cxx +98 -0
  53. package/deps/couchbase-cxx-client/core/impl/match_all_query.cxx +35 -0
  54. package/deps/couchbase-cxx-client/core/impl/match_none_query.cxx +35 -0
  55. package/deps/couchbase-cxx-client/core/impl/match_phrase_query.cxx +43 -0
  56. package/deps/couchbase-cxx-client/core/impl/match_query.cxx +59 -0
  57. package/deps/couchbase-cxx-client/core/impl/numeric_range.cxx +49 -0
  58. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet.cxx +54 -0
  59. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet_result.cxx +64 -0
  60. package/deps/couchbase-cxx-client/core/impl/numeric_range_query.cxx +56 -0
  61. package/deps/couchbase-cxx-client/core/impl/phrase_query.cxx +42 -0
  62. package/deps/couchbase-cxx-client/core/impl/prefix_query.cxx +40 -0
  63. package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +75 -0
  64. package/deps/couchbase-cxx-client/core/impl/query_string_query.cxx +37 -0
  65. package/deps/couchbase-cxx-client/core/impl/regexp_query.cxx +40 -0
  66. package/deps/couchbase-cxx-client/core/impl/search.cxx +191 -0
  67. package/deps/couchbase-cxx-client/core/impl/search_error_context.cxx +147 -0
  68. package/deps/couchbase-cxx-client/core/impl/search_meta_data.cxx +46 -0
  69. package/deps/couchbase-cxx-client/core/impl/search_result.cxx +66 -0
  70. package/deps/couchbase-cxx-client/core/impl/search_row.cxx +74 -0
  71. package/deps/couchbase-cxx-client/core/impl/search_row_location.cxx +64 -0
  72. package/deps/couchbase-cxx-client/core/impl/search_row_locations.cxx +66 -0
  73. package/deps/couchbase-cxx-client/core/impl/search_sort_field.cxx +104 -0
  74. package/deps/couchbase-cxx-client/core/impl/search_sort_id.cxx +43 -0
  75. package/deps/couchbase-cxx-client/core/impl/search_sort_score.cxx +43 -0
  76. package/deps/couchbase-cxx-client/core/impl/term_facet.cxx +36 -0
  77. package/deps/couchbase-cxx-client/core/impl/term_facet_result.cxx +64 -0
  78. package/deps/couchbase-cxx-client/core/impl/term_query.cxx +56 -0
  79. package/deps/couchbase-cxx-client/core/impl/term_range_query.cxx +57 -0
  80. package/deps/couchbase-cxx-client/core/impl/wildcard_query.cxx +40 -0
  81. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +9 -2
  82. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +54 -37
  83. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +4 -3
  84. package/deps/couchbase-cxx-client/core/json_string.hxx +5 -0
  85. package/deps/couchbase-cxx-client/core/meta/version.cxx +18 -4
  86. package/deps/couchbase-cxx-client/core/mozilla_ca_bundle.hxx +39 -0
  87. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +3 -1
  88. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -1
  89. package/deps/couchbase-cxx-client/core/protocol/client_request.hxx +11 -2
  90. package/deps/couchbase-cxx-client/core/protocol/client_response.hxx +1 -0
  91. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +59 -46
  92. package/deps/couchbase-cxx-client/core/utils/connection_string.hxx +1 -0
  93. package/deps/couchbase-cxx-client/couchbase/analytics_error_context.hxx +1 -1
  94. package/deps/couchbase-cxx-client/couchbase/boolean_field_query.hxx +77 -0
  95. package/deps/couchbase-cxx-client/couchbase/boolean_query.hxx +223 -0
  96. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +39 -0
  97. package/deps/couchbase-cxx-client/couchbase/conjunction_query.hxx +88 -0
  98. package/deps/couchbase-cxx-client/couchbase/date_range.hxx +69 -0
  99. package/deps/couchbase-cxx-client/couchbase/date_range_facet.hxx +56 -0
  100. package/deps/couchbase-cxx-client/couchbase/date_range_facet_result.hxx +55 -0
  101. package/deps/couchbase-cxx-client/couchbase/date_range_query.hxx +265 -0
  102. package/deps/couchbase-cxx-client/couchbase/disjunction_query.hxx +109 -0
  103. package/deps/couchbase-cxx-client/couchbase/doc_id_query.hxx +111 -0
  104. package/deps/couchbase-cxx-client/couchbase/error_context.hxx +17 -8
  105. package/deps/couchbase-cxx-client/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
  106. package/deps/couchbase-cxx-client/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
  107. package/deps/couchbase-cxx-client/couchbase/fmt/search_scan_consistency.hxx +49 -0
  108. package/deps/couchbase-cxx-client/couchbase/geo_bounding_box_query.hxx +107 -0
  109. package/deps/couchbase-cxx-client/couchbase/geo_distance_query.hxx +109 -0
  110. package/deps/couchbase-cxx-client/couchbase/geo_point.hxx +32 -0
  111. package/deps/couchbase-cxx-client/couchbase/geo_polygon_query.hxx +85 -0
  112. package/deps/couchbase-cxx-client/couchbase/highlight_style.hxx +45 -0
  113. package/deps/couchbase-cxx-client/couchbase/key_value_error_context.hxx +7 -2
  114. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +1 -1
  115. package/deps/couchbase-cxx-client/couchbase/match_all_query.hxx +43 -0
  116. package/deps/couchbase-cxx-client/couchbase/match_none_query.hxx +43 -0
  117. package/deps/couchbase-cxx-client/couchbase/match_operator.hxx +45 -0
  118. package/deps/couchbase-cxx-client/couchbase/match_phrase_query.hxx +108 -0
  119. package/deps/couchbase-cxx-client/couchbase/match_query.hxx +163 -0
  120. package/deps/couchbase-cxx-client/couchbase/numeric_range.hxx +58 -0
  121. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet.hxx +56 -0
  122. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet_result.hxx +55 -0
  123. package/deps/couchbase-cxx-client/couchbase/numeric_range_query.hxx +143 -0
  124. package/deps/couchbase-cxx-client/couchbase/phrase_query.hxx +93 -0
  125. package/deps/couchbase-cxx-client/couchbase/prefix_query.hxx +82 -0
  126. package/deps/couchbase-cxx-client/couchbase/query_error_context.hxx +3 -1
  127. package/deps/couchbase-cxx-client/couchbase/query_string_query.hxx +72 -0
  128. package/deps/couchbase-cxx-client/couchbase/regexp_query.hxx +82 -0
  129. package/deps/couchbase-cxx-client/couchbase/scope.hxx +39 -0
  130. package/deps/couchbase-cxx-client/couchbase/search_date_range.hxx +68 -0
  131. package/deps/couchbase-cxx-client/couchbase/search_error_context.hxx +138 -0
  132. package/deps/couchbase-cxx-client/couchbase/search_facet.hxx +60 -0
  133. package/deps/couchbase-cxx-client/couchbase/search_facet_result.hxx +50 -0
  134. package/deps/couchbase-cxx-client/couchbase/search_meta_data.hxx +85 -0
  135. package/deps/couchbase-cxx-client/couchbase/search_metrics.hxx +127 -0
  136. package/deps/couchbase-cxx-client/couchbase/search_numeric_range.hxx +69 -0
  137. package/deps/couchbase-cxx-client/couchbase/search_options.hxx +509 -0
  138. package/deps/couchbase-cxx-client/couchbase/search_query.hxx +69 -0
  139. package/deps/couchbase-cxx-client/couchbase/search_result.hxx +77 -0
  140. package/deps/couchbase-cxx-client/couchbase/search_row.hxx +104 -0
  141. package/deps/couchbase-cxx-client/couchbase/search_row_location.hxx +55 -0
  142. package/deps/couchbase-cxx-client/couchbase/search_row_locations.hxx +86 -0
  143. package/deps/couchbase-cxx-client/couchbase/search_scan_consistency.hxx +34 -0
  144. package/deps/couchbase-cxx-client/couchbase/search_sort.hxx +58 -0
  145. package/deps/couchbase-cxx-client/couchbase/search_sort_field.hxx +117 -0
  146. package/deps/couchbase-cxx-client/couchbase/search_sort_field_missing.hxx +26 -0
  147. package/deps/couchbase-cxx-client/couchbase/search_sort_field_mode.hxx +27 -0
  148. package/deps/couchbase-cxx-client/couchbase/search_sort_field_type.hxx +28 -0
  149. package/deps/couchbase-cxx-client/couchbase/search_sort_id.hxx +60 -0
  150. package/deps/couchbase-cxx-client/couchbase/search_sort_score.hxx +60 -0
  151. package/deps/couchbase-cxx-client/couchbase/search_term_range.hxx +51 -0
  152. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +3 -0
  153. package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +4 -2
  154. package/deps/couchbase-cxx-client/couchbase/term_facet.hxx +48 -0
  155. package/deps/couchbase-cxx-client/couchbase/term_facet_result.hxx +55 -0
  156. package/deps/couchbase-cxx-client/couchbase/term_query.hxx +151 -0
  157. package/deps/couchbase-cxx-client/couchbase/term_range_query.hxx +142 -0
  158. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +1 -1
  159. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +2 -1
  160. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_result.hxx +1 -1
  161. package/deps/couchbase-cxx-client/couchbase/transactions.hxx +3 -3
  162. package/deps/couchbase-cxx-client/couchbase/wildcard_query.hxx +83 -0
  163. package/deps/couchbase-cxx-client/docs/Doxyfile.in +1 -1
  164. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +2 -2
  165. package/deps/couchbase-cxx-client/docs/cbc-get.md +3 -2
  166. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +7 -2
  167. package/deps/couchbase-cxx-client/docs/cbc-query.md +2 -2
  168. package/deps/couchbase-cxx-client/docs/cbc.md +3 -3
  169. package/deps/couchbase-cxx-client/docs/cli.hxx +5 -5
  170. package/deps/couchbase-cxx-client/docs/mainpage.hxx +42 -5
  171. package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
  172. package/deps/couchbase-cxx-client/test/test_integration_analytics.cxx +28 -6
  173. package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +7 -3
  174. package/deps/couchbase-cxx-client/test/test_integration_connect.cxx +7 -3
  175. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +13 -3
  176. package/deps/couchbase-cxx-client/test/test_integration_diagnostics.cxx +8 -2
  177. package/deps/couchbase-cxx-client/test/test_integration_durability.cxx +12 -7
  178. package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +283 -11
  179. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +140 -88
  180. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +67 -9
  181. package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +12 -12
  182. package/deps/couchbase-cxx-client/test/test_integration_read_replica.cxx +48 -11
  183. package/deps/couchbase-cxx-client/test/test_integration_search.cxx +19 -1
  184. package/deps/couchbase-cxx-client/test/test_integration_subdoc.cxx +60 -9
  185. package/deps/couchbase-cxx-client/test/test_integration_tracer.cxx +3 -0
  186. package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +4 -0
  187. package/deps/couchbase-cxx-client/test/test_transaction_examples.cxx +100 -85
  188. package/deps/couchbase-cxx-client/test/test_unit_connection_string.cxx +29 -0
  189. package/deps/couchbase-cxx-client/test/test_unit_search.cxx +427 -0
  190. package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -1
  191. package/deps/couchbase-cxx-client/test/utils/logger.cxx +3 -1
  192. package/deps/couchbase-cxx-client/test/utils/server_version.hxx +31 -15
  193. package/deps/couchbase-cxx-client/test/utils/test_context.cxx +8 -0
  194. package/deps/couchbase-cxx-client/tools/get.cxx +9 -8
  195. package/deps/couchbase-cxx-client/tools/pillowfight.cxx +175 -75
  196. package/deps/couchbase-cxx-client/tools/version.cxx +4 -2
  197. package/dist/binding.d.ts +1 -1
  198. package/package.json +1 -1
  199. package/src/jstocbpp_autogen.hpp +3 -2
@@ -0,0 +1,55 @@
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/search_facet_result.hxx>
21
+ #include <couchbase/search_numeric_range.hxx>
22
+
23
+ #include <string>
24
+ #include <vector>
25
+
26
+ namespace couchbase
27
+ {
28
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
29
+ class internal_numeric_range_facet_result;
30
+ #endif
31
+
32
+ /**
33
+ * @since 1.0.0
34
+ * @committed
35
+ */
36
+ class numeric_range_facet_result : public search_facet_result
37
+ {
38
+ public:
39
+ /**
40
+ * @since 1.0.0
41
+ * @internal
42
+ */
43
+ explicit numeric_range_facet_result(internal_numeric_range_facet_result internal);
44
+
45
+ [[nodiscard]] auto name() const -> const std::string& override;
46
+ [[nodiscard]] auto field() const -> const std::string& override;
47
+ [[nodiscard]] auto total() const -> std::uint64_t override;
48
+ [[nodiscard]] auto missing() const -> std::uint64_t override;
49
+ [[nodiscard]] auto other() const -> std::uint64_t override;
50
+ [[nodiscard]] auto numeric_ranges() const -> const std::vector<search_numeric_range>&;
51
+
52
+ private:
53
+ std::unique_ptr<internal_numeric_range_facet_result> internal_;
54
+ };
55
+ } // namespace couchbase
@@ -0,0 +1,143 @@
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/match_operator.hxx>
21
+ #include <couchbase/search_query.hxx>
22
+
23
+ #include <cstdint>
24
+ #include <optional>
25
+ #include <string>
26
+
27
+ namespace couchbase
28
+ {
29
+ /**
30
+ * The numeric range query finds documents containing a numeric value in the specified field within the specified range. Either min or max
31
+ * can be omitted, but not both.
32
+ *
33
+ * By default, min is inclusive and max is exclusive.
34
+ *
35
+ * Match documents where field `id` contains numbers in the range `(100, 1000)`:
36
+ * @snippet test_unit_search.cxx search-numeric-range
37
+ *
38
+ * @since 1.0.0
39
+ * @committed
40
+ */
41
+ class numeric_range_query : public search_query
42
+ {
43
+ public:
44
+ /**
45
+ * Set lower limit of the range. Whether to include limit into the range will be decided by server defaults (inclusive).
46
+ *
47
+ * @param value lower limit of the range.
48
+ *
49
+ * @return this query for chaining purposes.
50
+ *
51
+ * @since 1.0.0
52
+ * @committed
53
+ */
54
+ auto min(double value) -> numeric_range_query&
55
+ {
56
+ min_ = value;
57
+ return *this;
58
+ }
59
+
60
+ /**
61
+ * Set lower limit and specify whether to include it into the limit.
62
+ *
63
+ * @param value lower limit of the range.
64
+ * @param inclusive whether to include limit value into the interval.
65
+ *
66
+ * @return this query for chaining purposes.
67
+ *
68
+ * @since 1.0.0
69
+ * @committed
70
+ */
71
+ auto min(double value, bool inclusive) -> numeric_range_query&
72
+ {
73
+ min_ = value;
74
+ inclusive_min_ = inclusive;
75
+ return *this;
76
+ }
77
+
78
+ /**
79
+ * Set upper limit of the range. Whether to include limit into the range will be decided by server defaults (exclusive).
80
+ *
81
+ * @param value upper limit of the range
82
+ *
83
+ * @return this query for chaining purposes.
84
+ *
85
+ * @since 1.0.0
86
+ * @committed
87
+ */
88
+ auto max(double value) -> numeric_range_query&
89
+ {
90
+ max_ = value;
91
+ return *this;
92
+ }
93
+
94
+ /**
95
+ * Set upper limit and specify whether to include it into the limit.
96
+ *
97
+ * @param value upper limit of the range.
98
+ * @param inclusive whether to include limit value into the interval.
99
+ *
100
+ * @return this query for chaining purposes.
101
+ *
102
+ * @since 1.0.0
103
+ * @committed
104
+ */
105
+ auto max(double value, bool inclusive) -> numeric_range_query&
106
+ {
107
+ max_ = value;
108
+ inclusive_max_ = inclusive;
109
+ return *this;
110
+ }
111
+
112
+ /**
113
+ * If a field is specified, only terms in that field will be matched.
114
+ *
115
+ * @param field_name name of the field to be matched
116
+ *
117
+ * @return this query for chaining purposes.
118
+ *
119
+ * @since 1.0.0
120
+ * @committed
121
+ */
122
+ auto field(std::string field_name) -> numeric_range_query&
123
+ {
124
+ field_ = std::move(field_name);
125
+ return *this;
126
+ }
127
+
128
+ /**
129
+ * @return encoded representation of the query.
130
+ *
131
+ * @since 1.0.0
132
+ * @internal
133
+ */
134
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
135
+
136
+ private:
137
+ std::optional<double> min_{};
138
+ std::optional<double> max_{};
139
+ std::optional<bool> inclusive_min_{};
140
+ std::optional<bool> inclusive_max_{};
141
+ std::optional<std::string> field_{};
142
+ };
143
+ } // namespace couchbase
@@ -0,0 +1,93 @@
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
+
22
+ #include <optional>
23
+ #include <stdexcept>
24
+ #include <string>
25
+ #include <vector>
26
+
27
+ namespace couchbase
28
+ {
29
+ /**
30
+ * A query that looks for **exact** match of several terms (in the exact order) in the index. The provided terms must exist in the correct
31
+ * order, at the correct index offsets, in the specified field (as no analyzer are applied to the terms). Queried field must have been
32
+ * indexed with `includeTermVectors` set to `true`. It is generally more useful in debugging scenarios, and the @ref match_phrase_query
33
+ * should usually be preferred for real-world use cases.
34
+ *
35
+ * Match documents with terms `"nice"` and `"view"` in field `reviews.content`:
36
+ * @snippet test_unit_search.cxx search-phrase
37
+ *
38
+ * @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-phrase.html server documentation
39
+ *
40
+ * @since 1.0.0
41
+ * @committed
42
+ */
43
+ class phrase_query : public search_query
44
+ {
45
+ public:
46
+ /**
47
+ * Create a new phrase query.
48
+ *
49
+ * The mandatory list of terms that must exactly match in the index. Note that the index can (and usually will) contain terms that are
50
+ * derived from the text in documents, as analyzers can apply process like stemming.
51
+ *
52
+ * @param terms non-empty vector of terms.
53
+ *
54
+ * @since 1.0.0
55
+ * @committed
56
+ */
57
+ explicit phrase_query(std::initializer_list<std::string> terms)
58
+ : terms_{ terms }
59
+ {
60
+ if (terms_.empty()) {
61
+ throw std::invalid_argument("terms must not be empty in phrase_query");
62
+ }
63
+ }
64
+
65
+ /**
66
+ * If a field is specified, only terms in that field will be matched.
67
+ *
68
+ * @param field_name name of the field to be matched
69
+ *
70
+ * @return this query for chaining purposes.
71
+ *
72
+ * @since 1.0.0
73
+ * @committed
74
+ */
75
+ auto field(std::string field_name) -> phrase_query&
76
+ {
77
+ field_ = std::move(field_name);
78
+ return *this;
79
+ }
80
+
81
+ /**
82
+ * @return encoded representation of the query.
83
+ *
84
+ * @since 1.0.0
85
+ * @internal
86
+ */
87
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
88
+
89
+ private:
90
+ std::vector<std::string> terms_;
91
+ std::optional<std::string> field_{};
92
+ };
93
+ } // namespace couchbase
@@ -0,0 +1,82 @@
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
+
22
+ #include <optional>
23
+ #include <string>
24
+
25
+ namespace couchbase
26
+ {
27
+ /**
28
+ * The prefix query finds documents containing terms that start with the provided prefix. Usual better alternative is @ref match_query.
29
+ *
30
+ * Match documents where field `reviews.content` contains words starting with `"inter"`:
31
+ * @snippet test_unit_search.cxx search-prefix
32
+ *
33
+ * @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-prefix-query.html server documentation
34
+ *
35
+ * @since 1.0.0
36
+ * @committed
37
+ */
38
+ class prefix_query : public search_query
39
+ {
40
+ public:
41
+ /**
42
+ * Create a new prefix query.
43
+ *
44
+ * @param prefix prefix to match
45
+ *
46
+ * @since 1.0.0
47
+ * @committed
48
+ */
49
+ explicit prefix_query(std::string prefix)
50
+ : prefix_{ std::move(prefix) }
51
+ {
52
+ }
53
+
54
+ /**
55
+ * If a field is specified, only terms in that field will be matched.
56
+ *
57
+ * @param field_name name of the field to be matched
58
+ *
59
+ * @return this query for chaining purposes.
60
+ *
61
+ * @since 1.0.0
62
+ * @committed
63
+ */
64
+ auto field(std::string field_name) -> prefix_query&
65
+ {
66
+ field_ = std::move(field_name);
67
+ return *this;
68
+ }
69
+
70
+ /**
71
+ * @return encoded representation of the query.
72
+ *
73
+ * @since 1.0.0
74
+ * @internal
75
+ */
76
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
77
+
78
+ private:
79
+ std::string prefix_;
80
+ std::optional<std::string> field_{};
81
+ };
82
+ } // namespace couchbase
@@ -57,7 +57,7 @@ class query_error_context : public error_context
57
57
  std::string http_body,
58
58
  std::string hostname,
59
59
  std::uint16_t port)
60
- : error_context{ ec, std::move(last_dispatched_to), std::move(last_dispatched_from), retry_attempts, std::move(retry_reasons) }
60
+ : error_context{ {}, ec, std::move(last_dispatched_to), std::move(last_dispatched_from), retry_attempts, std::move(retry_reasons) }
61
61
  , first_error_code_{ first_error_code }
62
62
  , first_error_message_{ std::move(first_error_message) }
63
63
  , client_context_id_{ std::move(client_context_id) }
@@ -127,6 +127,8 @@ class query_error_context : public error_context
127
127
  return port_;
128
128
  }
129
129
 
130
+ [[nodiscard]] auto to_json() const -> std::string;
131
+
130
132
  private:
131
133
  std::uint64_t first_error_code_{};
132
134
  std::string first_error_message_{};
@@ -0,0 +1,72 @@
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
+
22
+ #include <string>
23
+
24
+ namespace couchbase
25
+ {
26
+ /**
27
+ * The query string query allows humans to describe complex queries using a simple syntax.
28
+ *
29
+ * 1. When you specify multiple query-clauses, you can specify the relative importance to a given clause by suffixing it with the `^`
30
+ * operator, followed by a number or by specifying the boost parameter with the number to boost the search. For example perform
31
+ * @ref match_query for pool in both the name and description fields, but documents having the term in the name field score higher.
32
+ * @snippet test_unit_search.cxx search-query-string-boosting
33
+ *
34
+ * 2. You can perform date or numeric range searches by using the `>`, `>=`, `<`, and `<=` operators, followed by a date value in quotes.
35
+ * For example, perform a @ref date_range_query on the created field for values after September 21, 2016.
36
+ * @snippet test_unit_search.cxx search-query-string-date-range
37
+ * Or, perform a @ref numeric_range_query on the `reviews.ratings.Cleanliness` field, for values greater than 4.
38
+ * @snippet test_unit_search.cxx search-query-string-numeric-range
39
+ *
40
+ * @see https://docs.couchbase.com/server/current/fts/fts-query-string-syntax.html definition of query syntax
41
+ *
42
+ * @since 1.0.0
43
+ * @committed
44
+ */
45
+ class query_string_query : public search_query
46
+ {
47
+ public:
48
+ /**
49
+ * Create a new query string query.
50
+ *
51
+ * @param query the query string to be analyzed and used against
52
+ *
53
+ * @since 1.0.0
54
+ * @committed
55
+ */
56
+ explicit query_string_query(std::string query)
57
+ : query_{ std::move(query) }
58
+ {
59
+ }
60
+
61
+ /**
62
+ * @return encoded representation of the query.
63
+ *
64
+ * @since 1.0.0
65
+ * @internal
66
+ */
67
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
68
+
69
+ private:
70
+ std::string query_;
71
+ };
72
+ } // namespace couchbase
@@ -0,0 +1,82 @@
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
+
22
+ #include <optional>
23
+ #include <string>
24
+
25
+ namespace couchbase
26
+ {
27
+ /**
28
+ * Finds documents containing terms that match the specified regular expression.
29
+ *
30
+ * Match documents where field `reviews.content` contains words starting with `"inter"`:
31
+ * @snippet test_unit_search.cxx search-regexp
32
+ *
33
+ * @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-regexp.html server documentation
34
+ *
35
+ * @since 1.0.0
36
+ * @committed
37
+ */
38
+ class regexp_query : public search_query
39
+ {
40
+ public:
41
+ /**
42
+ * Create a new regexp query.
43
+ *
44
+ * @param regexp the input string to be matched against
45
+ *
46
+ * @since 1.0.0
47
+ * @committed
48
+ */
49
+ explicit regexp_query(std::string regexp)
50
+ : regexp_{ std::move(regexp) }
51
+ {
52
+ }
53
+
54
+ /**
55
+ * If a field is specified, only terms in that field will be matched.
56
+ *
57
+ * @param field_name name of the field to be matched
58
+ *
59
+ * @return this query for chaining purposes.
60
+ *
61
+ * @since 1.0.0
62
+ * @committed
63
+ */
64
+ auto field(std::string field_name) -> regexp_query&
65
+ {
66
+ field_ = std::move(field_name);
67
+ return *this;
68
+ }
69
+
70
+ /**
71
+ * @return encoded representation of the query.
72
+ *
73
+ * @since 1.0.0
74
+ * @internal
75
+ */
76
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
77
+
78
+ private:
79
+ std::string regexp_;
80
+ std::optional<std::string> field_{};
81
+ };
82
+ } // namespace couchbase
@@ -20,6 +20,8 @@
20
20
  #include <couchbase/analytics_options.hxx>
21
21
  #include <couchbase/collection.hxx>
22
22
  #include <couchbase/query_options.hxx>
23
+ #include <couchbase/search_options.hxx>
24
+ #include <couchbase/search_query.hxx>
23
25
 
24
26
  #include <memory>
25
27
 
@@ -134,6 +136,43 @@ class scope
134
136
  return future;
135
137
  }
136
138
 
139
+ /**
140
+ * Performs a query against the full text search services.
141
+ *
142
+ * @param index_name name of the search index
143
+ * @param query query object, see hierarchy of @ref search_query for more details.
144
+ * @param options options to customize the query request.
145
+ * @param handler the handler that implements @ref search_handler
146
+ *
147
+ * @exception errc::common::ambiguous_timeout
148
+ * @exception errc::common::unambiguous_timeout
149
+ *
150
+ * @see https://docs.couchbase.com/server/current/fts/fts-introduction.html
151
+ *
152
+ * @since 1.0.0
153
+ * @committed
154
+ */
155
+ void search_query(std::string index_name, const search_query& query, const search_options& options, search_handler&& handler) const;
156
+
157
+ /**
158
+ * Performs a query against the full text search services.
159
+ *
160
+ * @param index_name name of the search index
161
+ * @param query query object, see hierarchy of @ref search_query for more details.
162
+ * @param options options to customize the query request.
163
+ * @return future object that carries result of the operation
164
+ *
165
+ * @exception errc::common::ambiguous_timeout
166
+ * @exception errc::common::unambiguous_timeout
167
+ *
168
+ * @see https://docs.couchbase.com/server/current/fts/fts-introduction.html
169
+ *
170
+ * @since 1.0.0
171
+ * @committed
172
+ */
173
+ [[nodiscard]] auto search_query(std::string index_name, const class search_query& query, const search_options& options = {}) const
174
+ -> std::future<std::pair<search_error_context, search_result>>;
175
+
137
176
  /**
138
177
  * Performs a query against the analytics services.
139
178
  *
@@ -0,0 +1,68 @@
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 <chrono>
21
+ #include <cinttypes>
22
+ #include <optional>
23
+ #include <string>
24
+
25
+ namespace couchbase
26
+ {
27
+ /**
28
+ * @since 1.0.0
29
+ * @committed
30
+ */
31
+ class search_date_range
32
+ {
33
+ public:
34
+ search_date_range(std::string name, std::optional<std::string> start, std::optional<std::string> end, std::uint64_t count)
35
+ : name_{ std::move(name) }
36
+ , start_{ std::move(start) }
37
+ , end_{ std::move(end) }
38
+ , count_{ count }
39
+ {
40
+ }
41
+
42
+ [[nodiscard]] auto name() const -> const std::string&
43
+ {
44
+ return name_;
45
+ }
46
+
47
+ [[nodiscard]] auto start() const -> const std::optional<std::string>&
48
+ {
49
+ return start_;
50
+ }
51
+
52
+ [[nodiscard]] auto end() const -> const std::optional<std::string>&
53
+ {
54
+ return end_;
55
+ }
56
+
57
+ [[nodiscard]] auto count() const -> std::uint64_t
58
+ {
59
+ return count_;
60
+ }
61
+
62
+ private:
63
+ std::string name_;
64
+ std::optional<std::string> start_;
65
+ std::optional<std::string> end_;
66
+ std::uint64_t count_;
67
+ };
68
+ } // namespace couchbase