couchbase 4.2.3 → 4.2.5-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/CMakeLists.txt +136 -11
  2. package/deps/couchbase-cxx-client/CMakeLists.txt +54 -4
  3. package/deps/couchbase-cxx-client/README.md +1 -0
  4. package/deps/couchbase-cxx-client/bin/create-search-index +164 -0
  5. package/deps/couchbase-cxx-client/bin/init-cluster +55 -10
  6. package/deps/couchbase-cxx-client/bin/run-unit-tests +62 -6
  7. package/deps/couchbase-cxx-client/bin/travel-sample-index-v6.json +184 -0
  8. package/deps/couchbase-cxx-client/bin/travel-sample-index.json +188 -0
  9. package/deps/couchbase-cxx-client/cmake/Documentation.cmake +0 -1
  10. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +98 -3
  11. package/deps/couchbase-cxx-client/cmake/Testing.cmake +8 -0
  12. package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +3 -0
  13. package/deps/couchbase-cxx-client/core/bucket.cxx +183 -152
  14. package/deps/couchbase-cxx-client/core/bucket.hxx +17 -4
  15. package/deps/couchbase-cxx-client/core/cluster.hxx +18 -1
  16. package/deps/couchbase-cxx-client/core/cluster_options.hxx +1 -0
  17. package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +2 -1
  18. package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +10 -12
  19. package/deps/couchbase-cxx-client/core/error_context/search.hxx +1 -1
  20. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
  21. package/deps/couchbase-cxx-client/core/impl/boolean_field_query.cxx +40 -0
  22. package/deps/couchbase-cxx-client/core/impl/boolean_query.cxx +62 -0
  23. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -0
  24. package/deps/couchbase-cxx-client/core/impl/conjunction_query.cxx +51 -0
  25. package/deps/couchbase-cxx-client/core/impl/date_range.cxx +89 -0
  26. package/deps/couchbase-cxx-client/core/impl/date_range_facet.cxx +54 -0
  27. package/deps/couchbase-cxx-client/core/impl/date_range_facet_result.cxx +64 -0
  28. package/deps/couchbase-cxx-client/core/impl/date_range_query.cxx +125 -0
  29. package/deps/couchbase-cxx-client/core/impl/disjunction_query.cxx +51 -0
  30. package/deps/couchbase-cxx-client/core/impl/encoded_search_facet.hxx +29 -0
  31. package/deps/couchbase-cxx-client/core/impl/encoded_search_query.hxx +29 -0
  32. package/deps/couchbase-cxx-client/core/impl/encoded_search_sort.hxx +29 -0
  33. package/deps/couchbase-cxx-client/core/impl/geo_bounding_box_query.cxx +46 -0
  34. package/deps/couchbase-cxx-client/core/impl/geo_distance_query.cxx +43 -0
  35. package/deps/couchbase-cxx-client/core/impl/geo_polygon_query.cxx +46 -0
  36. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.cxx +80 -0
  37. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.hxx +48 -0
  38. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.cxx +80 -0
  39. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.hxx +48 -0
  40. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.cxx +141 -0
  41. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.hxx +61 -0
  42. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.cxx +60 -0
  43. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.hxx +41 -0
  44. package/deps/couchbase-cxx-client/core/impl/internal_search_result.cxx +84 -0
  45. package/deps/couchbase-cxx-client/core/impl/internal_search_result.hxx +43 -0
  46. package/deps/couchbase-cxx-client/core/impl/internal_search_row.cxx +82 -0
  47. package/deps/couchbase-cxx-client/core/impl/internal_search_row.hxx +56 -0
  48. package/deps/couchbase-cxx-client/core/impl/internal_search_row_location.hxx +32 -0
  49. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.cxx +137 -0
  50. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.hxx +45 -0
  51. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.cxx +80 -0
  52. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.hxx +48 -0
  53. package/deps/couchbase-cxx-client/core/impl/key_value_error_context.cxx +98 -0
  54. package/deps/couchbase-cxx-client/core/impl/match_all_query.cxx +35 -0
  55. package/deps/couchbase-cxx-client/core/impl/match_none_query.cxx +35 -0
  56. package/deps/couchbase-cxx-client/core/impl/match_phrase_query.cxx +43 -0
  57. package/deps/couchbase-cxx-client/core/impl/match_query.cxx +59 -0
  58. package/deps/couchbase-cxx-client/core/impl/numeric_range.cxx +49 -0
  59. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet.cxx +54 -0
  60. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet_result.cxx +64 -0
  61. package/deps/couchbase-cxx-client/core/impl/numeric_range_query.cxx +56 -0
  62. package/deps/couchbase-cxx-client/core/impl/phrase_query.cxx +42 -0
  63. package/deps/couchbase-cxx-client/core/impl/prefix_query.cxx +40 -0
  64. package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +75 -0
  65. package/deps/couchbase-cxx-client/core/impl/query_string_query.cxx +37 -0
  66. package/deps/couchbase-cxx-client/core/impl/regexp_query.cxx +40 -0
  67. package/deps/couchbase-cxx-client/core/impl/search.cxx +191 -0
  68. package/deps/couchbase-cxx-client/core/impl/search_error_context.cxx +147 -0
  69. package/deps/couchbase-cxx-client/core/impl/search_meta_data.cxx +46 -0
  70. package/deps/couchbase-cxx-client/core/impl/search_result.cxx +66 -0
  71. package/deps/couchbase-cxx-client/core/impl/search_row.cxx +74 -0
  72. package/deps/couchbase-cxx-client/core/impl/search_row_location.cxx +64 -0
  73. package/deps/couchbase-cxx-client/core/impl/search_row_locations.cxx +66 -0
  74. package/deps/couchbase-cxx-client/core/impl/search_sort_field.cxx +104 -0
  75. package/deps/couchbase-cxx-client/core/impl/search_sort_id.cxx +43 -0
  76. package/deps/couchbase-cxx-client/core/impl/search_sort_score.cxx +43 -0
  77. package/deps/couchbase-cxx-client/core/impl/term_facet.cxx +36 -0
  78. package/deps/couchbase-cxx-client/core/impl/term_facet_result.cxx +64 -0
  79. package/deps/couchbase-cxx-client/core/impl/term_query.cxx +56 -0
  80. package/deps/couchbase-cxx-client/core/impl/term_range_query.cxx +57 -0
  81. package/deps/couchbase-cxx-client/core/impl/wildcard_query.cxx +40 -0
  82. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +9 -2
  83. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +54 -37
  84. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +4 -3
  85. package/deps/couchbase-cxx-client/core/json_string.hxx +5 -0
  86. package/deps/couchbase-cxx-client/core/meta/version.cxx +18 -4
  87. package/deps/couchbase-cxx-client/core/mozilla_ca_bundle.hxx +39 -0
  88. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +3 -1
  89. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -1
  90. package/deps/couchbase-cxx-client/core/protocol/client_request.hxx +11 -2
  91. package/deps/couchbase-cxx-client/core/protocol/client_response.hxx +1 -0
  92. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +59 -46
  93. package/deps/couchbase-cxx-client/core/utils/connection_string.hxx +1 -0
  94. package/deps/couchbase-cxx-client/couchbase/analytics_error_context.hxx +1 -1
  95. package/deps/couchbase-cxx-client/couchbase/boolean_field_query.hxx +77 -0
  96. package/deps/couchbase-cxx-client/couchbase/boolean_query.hxx +223 -0
  97. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +39 -0
  98. package/deps/couchbase-cxx-client/couchbase/conjunction_query.hxx +88 -0
  99. package/deps/couchbase-cxx-client/couchbase/date_range.hxx +69 -0
  100. package/deps/couchbase-cxx-client/couchbase/date_range_facet.hxx +56 -0
  101. package/deps/couchbase-cxx-client/couchbase/date_range_facet_result.hxx +55 -0
  102. package/deps/couchbase-cxx-client/couchbase/date_range_query.hxx +265 -0
  103. package/deps/couchbase-cxx-client/couchbase/disjunction_query.hxx +109 -0
  104. package/deps/couchbase-cxx-client/couchbase/doc_id_query.hxx +111 -0
  105. package/deps/couchbase-cxx-client/couchbase/error_context.hxx +17 -8
  106. package/deps/couchbase-cxx-client/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
  107. package/deps/couchbase-cxx-client/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
  108. package/deps/couchbase-cxx-client/couchbase/fmt/search_scan_consistency.hxx +49 -0
  109. package/deps/couchbase-cxx-client/couchbase/geo_bounding_box_query.hxx +107 -0
  110. package/deps/couchbase-cxx-client/couchbase/geo_distance_query.hxx +109 -0
  111. package/deps/couchbase-cxx-client/couchbase/geo_point.hxx +32 -0
  112. package/deps/couchbase-cxx-client/couchbase/geo_polygon_query.hxx +85 -0
  113. package/deps/couchbase-cxx-client/couchbase/highlight_style.hxx +45 -0
  114. package/deps/couchbase-cxx-client/couchbase/key_value_error_context.hxx +7 -2
  115. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +1 -1
  116. package/deps/couchbase-cxx-client/couchbase/match_all_query.hxx +43 -0
  117. package/deps/couchbase-cxx-client/couchbase/match_none_query.hxx +43 -0
  118. package/deps/couchbase-cxx-client/couchbase/match_operator.hxx +45 -0
  119. package/deps/couchbase-cxx-client/couchbase/match_phrase_query.hxx +108 -0
  120. package/deps/couchbase-cxx-client/couchbase/match_query.hxx +163 -0
  121. package/deps/couchbase-cxx-client/couchbase/numeric_range.hxx +58 -0
  122. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet.hxx +56 -0
  123. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet_result.hxx +55 -0
  124. package/deps/couchbase-cxx-client/couchbase/numeric_range_query.hxx +143 -0
  125. package/deps/couchbase-cxx-client/couchbase/phrase_query.hxx +93 -0
  126. package/deps/couchbase-cxx-client/couchbase/prefix_query.hxx +82 -0
  127. package/deps/couchbase-cxx-client/couchbase/query_error_context.hxx +3 -1
  128. package/deps/couchbase-cxx-client/couchbase/query_string_query.hxx +72 -0
  129. package/deps/couchbase-cxx-client/couchbase/regexp_query.hxx +82 -0
  130. package/deps/couchbase-cxx-client/couchbase/scope.hxx +39 -0
  131. package/deps/couchbase-cxx-client/couchbase/search_date_range.hxx +68 -0
  132. package/deps/couchbase-cxx-client/couchbase/search_error_context.hxx +138 -0
  133. package/deps/couchbase-cxx-client/couchbase/search_facet.hxx +60 -0
  134. package/deps/couchbase-cxx-client/couchbase/search_facet_result.hxx +50 -0
  135. package/deps/couchbase-cxx-client/couchbase/search_meta_data.hxx +85 -0
  136. package/deps/couchbase-cxx-client/couchbase/search_metrics.hxx +127 -0
  137. package/deps/couchbase-cxx-client/couchbase/search_numeric_range.hxx +69 -0
  138. package/deps/couchbase-cxx-client/couchbase/search_options.hxx +509 -0
  139. package/deps/couchbase-cxx-client/couchbase/search_query.hxx +69 -0
  140. package/deps/couchbase-cxx-client/couchbase/search_result.hxx +77 -0
  141. package/deps/couchbase-cxx-client/couchbase/search_row.hxx +104 -0
  142. package/deps/couchbase-cxx-client/couchbase/search_row_location.hxx +55 -0
  143. package/deps/couchbase-cxx-client/couchbase/search_row_locations.hxx +86 -0
  144. package/deps/couchbase-cxx-client/couchbase/search_scan_consistency.hxx +34 -0
  145. package/deps/couchbase-cxx-client/couchbase/search_sort.hxx +58 -0
  146. package/deps/couchbase-cxx-client/couchbase/search_sort_field.hxx +117 -0
  147. package/deps/couchbase-cxx-client/couchbase/search_sort_field_missing.hxx +26 -0
  148. package/deps/couchbase-cxx-client/couchbase/search_sort_field_mode.hxx +27 -0
  149. package/deps/couchbase-cxx-client/couchbase/search_sort_field_type.hxx +28 -0
  150. package/deps/couchbase-cxx-client/couchbase/search_sort_id.hxx +60 -0
  151. package/deps/couchbase-cxx-client/couchbase/search_sort_score.hxx +60 -0
  152. package/deps/couchbase-cxx-client/couchbase/search_term_range.hxx +51 -0
  153. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +3 -0
  154. package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +4 -2
  155. package/deps/couchbase-cxx-client/couchbase/term_facet.hxx +48 -0
  156. package/deps/couchbase-cxx-client/couchbase/term_facet_result.hxx +55 -0
  157. package/deps/couchbase-cxx-client/couchbase/term_query.hxx +151 -0
  158. package/deps/couchbase-cxx-client/couchbase/term_range_query.hxx +142 -0
  159. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +1 -1
  160. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +2 -1
  161. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_result.hxx +1 -1
  162. package/deps/couchbase-cxx-client/couchbase/transactions.hxx +3 -3
  163. package/deps/couchbase-cxx-client/couchbase/wildcard_query.hxx +83 -0
  164. package/deps/couchbase-cxx-client/docs/Doxyfile.in +1 -1
  165. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +2 -2
  166. package/deps/couchbase-cxx-client/docs/cbc-get.md +3 -2
  167. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +7 -2
  168. package/deps/couchbase-cxx-client/docs/cbc-query.md +2 -2
  169. package/deps/couchbase-cxx-client/docs/cbc.md +3 -3
  170. package/deps/couchbase-cxx-client/docs/cli.hxx +5 -5
  171. package/deps/couchbase-cxx-client/docs/mainpage.hxx +42 -5
  172. package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
  173. package/deps/couchbase-cxx-client/test/test_integration_analytics.cxx +28 -6
  174. package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +7 -3
  175. package/deps/couchbase-cxx-client/test/test_integration_connect.cxx +7 -3
  176. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +13 -3
  177. package/deps/couchbase-cxx-client/test/test_integration_diagnostics.cxx +8 -2
  178. package/deps/couchbase-cxx-client/test/test_integration_durability.cxx +12 -7
  179. package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +283 -11
  180. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +140 -88
  181. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +67 -9
  182. package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +12 -12
  183. package/deps/couchbase-cxx-client/test/test_integration_read_replica.cxx +48 -11
  184. package/deps/couchbase-cxx-client/test/test_integration_search.cxx +19 -1
  185. package/deps/couchbase-cxx-client/test/test_integration_subdoc.cxx +60 -9
  186. package/deps/couchbase-cxx-client/test/test_integration_tracer.cxx +3 -0
  187. package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +4 -0
  188. package/deps/couchbase-cxx-client/test/test_transaction_examples.cxx +100 -85
  189. package/deps/couchbase-cxx-client/test/test_unit_connection_string.cxx +29 -0
  190. package/deps/couchbase-cxx-client/test/test_unit_search.cxx +427 -0
  191. package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -1
  192. package/deps/couchbase-cxx-client/test/utils/logger.cxx +3 -1
  193. package/deps/couchbase-cxx-client/test/utils/server_version.hxx +31 -15
  194. package/deps/couchbase-cxx-client/test/utils/test_context.cxx +8 -0
  195. package/deps/couchbase-cxx-client/tools/get.cxx +9 -8
  196. package/deps/couchbase-cxx-client/tools/pillowfight.cxx +175 -75
  197. package/deps/couchbase-cxx-client/tools/version.cxx +4 -2
  198. package/dist/binding.d.ts +1 -1
  199. package/dist/binding.js +3 -2
  200. package/package.json +96 -1
  201. package/scripts/createPlatformPackages.js +108 -0
  202. package/scripts/install.js +45 -0
  203. package/scripts/prebuilds.js +249 -0
  204. package/scripts/prune.js +124 -0
  205. package/src/jstocbpp_autogen.hpp +3 -2
@@ -0,0 +1,88 @@
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 <memory>
23
+ #include <vector>
24
+
25
+ namespace couchbase
26
+ {
27
+ /**
28
+ * The conjunction query is a compound query. The result documents must satisfy all of the child queries. It is possible to recursively nest
29
+ * compound queries.
30
+ *
31
+ * At execution, a conjunction query that has no child queries is not allowed and will fail fast.
32
+ *
33
+ * Match documents with `"location"` in the field `reviews.content` and `true` in the field `free_breakfast`.
34
+ * @snippet test_unit_search.cxx search-conjunction
35
+ *
36
+ * @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-conjuncts-disjuncts.html server documentation
37
+ *
38
+ * @since 1.0.0
39
+ * @committed
40
+ */
41
+ class conjunction_query : public search_query
42
+ {
43
+ public:
44
+ /**
45
+ * Create a conjunction query.
46
+ *
47
+ * @tparam SearchQuery any subclass of @ref search_query
48
+ * @param queries sequence of query arguments
49
+ *
50
+ * @since 1.0.0
51
+ * @committed
52
+ */
53
+ template<typename... SearchQuery>
54
+ explicit conjunction_query(SearchQuery&&... queries)
55
+ {
56
+ and_also(std::forward<SearchQuery>(queries)...);
57
+ }
58
+
59
+ /**
60
+ * Add one or more queries to add to the conjunction.
61
+ *
62
+ * @tparam SearchQuery any subclass of @ref search_query
63
+ * @param queries sequence of query arguments
64
+ *
65
+ * @return this query for chaining purposes.
66
+ *
67
+ * @since 1.0.0
68
+ * @committed
69
+ */
70
+ template<typename... SearchQuery>
71
+ auto and_also(SearchQuery... queries) -> conjunction_query&
72
+ {
73
+ (conjuncts_.emplace_back(std::make_shared<SearchQuery>(std::move(queries))), ...);
74
+ return *this;
75
+ }
76
+
77
+ /**
78
+ * @return encoded representation of the query.
79
+ *
80
+ * @since 1.0.0
81
+ * @internal
82
+ */
83
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
84
+
85
+ private:
86
+ std::vector<std::shared_ptr<search_query>> conjuncts_{};
87
+ };
88
+ } // namespace couchbase
@@ -0,0 +1,69 @@
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 <cstdint>
22
+ #include <ctime>
23
+ #include <optional>
24
+ #include <string>
25
+ #include <variant>
26
+
27
+ namespace couchbase
28
+ {
29
+ /**
30
+ * Date range for @ref date_range_facet.
31
+ */
32
+ class date_range
33
+ {
34
+ public:
35
+ date_range(std::string name, std::string start, std::string end);
36
+ date_range(std::string name, std::chrono::system_clock::time_point start, std::chrono::system_clock::time_point end);
37
+ date_range(std::string name, std::tm start, std::tm end);
38
+
39
+ static date_range with_start(std::string name, std::string start);
40
+ static date_range with_start(std::string name, std::chrono::system_clock::time_point start);
41
+ static date_range with_start(std::string name, std::tm start);
42
+
43
+ static date_range with_end(std::string name, std::string end);
44
+ static date_range with_end(std::string name, std::chrono::system_clock::time_point end);
45
+ static date_range with_end(std::string name, std::tm end);
46
+
47
+ [[nodiscard]] auto name() const -> const std::string&
48
+ {
49
+ return name_;
50
+ }
51
+
52
+ [[nodiscard]] auto start() const -> const std::optional<std::string>&
53
+ {
54
+ return start_;
55
+ }
56
+
57
+ [[nodiscard]] auto end() const -> const std::optional<std::string>&
58
+ {
59
+ return end_;
60
+ }
61
+
62
+ private:
63
+ date_range(std::string name, std::optional<std::string> start, std::optional<std::string> end);
64
+
65
+ std::string name_;
66
+ std::optional<std::string> start_{};
67
+ std::optional<std::string> end_{};
68
+ };
69
+ } // namespace couchbase
@@ -0,0 +1,56 @@
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/date_range.hxx>
21
+ #include <couchbase/search_facet.hxx>
22
+
23
+ #include <vector>
24
+
25
+ namespace couchbase
26
+ {
27
+ /**
28
+ * A facet that categorizes rows into dateal ranges (or buckets) provided by the user.
29
+ */
30
+ class date_range_facet : public search_facet
31
+ {
32
+ public:
33
+ date_range_facet(std::string field, std::vector<date_range> ranges)
34
+ : search_facet{ std::move(field) }
35
+ , ranges_{ std::move(ranges) }
36
+ {
37
+ }
38
+
39
+ date_range_facet(std::string field, std::uint32_t size, std::vector<date_range> ranges)
40
+ : search_facet{ std::move(field), size }
41
+ , ranges_{ std::move(ranges) }
42
+ {
43
+ }
44
+
45
+ /**
46
+ * @return encoded representation of the search facet.
47
+ *
48
+ * @since 1.0.0
49
+ * @internal
50
+ */
51
+ [[nodiscard]] auto encode() const -> encoded_search_facet override;
52
+
53
+ private:
54
+ std::vector<date_range> ranges_;
55
+ };
56
+ } // namespace couchbase
@@ -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_date_range.hxx>
21
+ #include <couchbase/search_facet_result.hxx>
22
+
23
+ #include <string>
24
+ #include <vector>
25
+
26
+ namespace couchbase
27
+ {
28
+ #ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
29
+ class internal_date_range_facet_result;
30
+ #endif
31
+
32
+ /**
33
+ * @since 1.0.0
34
+ * @committed
35
+ */
36
+ class date_range_facet_result : public search_facet_result
37
+ {
38
+ public:
39
+ /**
40
+ * @since 1.0.0
41
+ * @internal
42
+ */
43
+ explicit date_range_facet_result(internal_date_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 date_ranges() const -> const std::vector<search_date_range>&;
51
+
52
+ private:
53
+ std::unique_ptr<internal_date_range_facet_result> internal_;
54
+ };
55
+ } // namespace couchbase
@@ -0,0 +1,265 @@
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 <chrono>
24
+ #include <cstdint>
25
+ #include <ctime>
26
+ #include <optional>
27
+ #include <string>
28
+
29
+ namespace couchbase
30
+ {
31
+ /**
32
+ * The date range query finds documents containing a date value in the specified field within the specified range. Either start or end can
33
+ * be omitted, but not both.
34
+ *
35
+ * Match documents where field `review_date` falls within the range ("2001-10-09T10:20:30-08:00", "2016-10-31")
36
+ * @snippet test_unit_search.cxx search-date-range
37
+ *
38
+ * It also works with `std::tm` and `std::chrono::system_clock::time_point`.
39
+ * @snippet test_unit_search.cxx search-date-range-tm
40
+ *
41
+ * @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-date-range.html server documentation.
42
+ *
43
+ * @since 1.0.0
44
+ * @committed
45
+ */
46
+ class date_range_query : public search_query
47
+ {
48
+ public:
49
+ /**
50
+ * Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.
51
+ *
52
+ * @param value start limit time point
53
+ *
54
+ * @return this query for chaining purposes.
55
+ *
56
+ * @since 1.0.0
57
+ * @committed
58
+ */
59
+ auto start(std::chrono::system_clock::time_point value) -> date_range_query&;
60
+
61
+ /**
62
+ * Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.
63
+ *
64
+ * @param value start limit as a `tm` (broken down timestamp)
65
+ *
66
+ * @return this query for chaining purposes.
67
+ *
68
+ * @since 1.0.0
69
+ * @committed
70
+ */
71
+ auto start(std::tm value) -> date_range_query&;
72
+
73
+ /**
74
+ * Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.
75
+ *
76
+ * @param value start limit time point
77
+ * @param inclusive whether to include limit value into the interval.
78
+ *
79
+ * @return this query for chaining purposes.
80
+ *
81
+ * @since 1.0.0
82
+ * @committed
83
+ */
84
+ auto start(std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query&;
85
+
86
+ /**
87
+ * Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.
88
+ *
89
+ * @param value start limit as a `tm` (broken down timestamp)
90
+ * @param inclusive whether to include limit value into the interval.
91
+ *
92
+ * @return this query for chaining purposes.
93
+ *
94
+ * @since 1.0.0
95
+ * @committed
96
+ */
97
+ auto start(std::tm value, bool inclusive) -> date_range_query&;
98
+
99
+ /**
100
+ * Set preformatted date as lower limit.
101
+ *
102
+ * @param value start limit formatted as a string, use @ref date_time_parser() for non-standard formats
103
+ *
104
+ * @return this query for chaining purposes.
105
+ *
106
+ * @since 1.0.0
107
+ * @committed
108
+ */
109
+ auto start(std::string value) -> date_range_query&
110
+ {
111
+ start_ = std::move(value);
112
+ return *this;
113
+ }
114
+
115
+ /**
116
+ * Set preformatted date as lower limit.
117
+ *
118
+ * @param value start limit formatted as a string, use @ref date_time_parser() for non-standard formats
119
+ * @param inclusive whether to include limit value into the interval.
120
+ *
121
+ * @return this query for chaining purposes.
122
+ *
123
+ * @since 1.0.0
124
+ * @committed
125
+ */
126
+ auto start(std::string value, bool inclusive) -> date_range_query&
127
+ {
128
+ start_ = std::move(value);
129
+ inclusive_start_ = inclusive;
130
+ return *this;
131
+ }
132
+
133
+ /**
134
+ * Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.
135
+ *
136
+ * @param value end limit time point
137
+ *
138
+ * @return this query for chaining purposes.
139
+ *
140
+ * @since 1.0.0
141
+ * @committed
142
+ */
143
+ auto end(std::chrono::system_clock::time_point value) -> date_range_query&;
144
+
145
+ /**
146
+ * Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.
147
+ *
148
+ * @param value end limit as a `tm` (broken down timestamp)
149
+ *
150
+ * @return this query for chaining purposes.
151
+ *
152
+ * @since 1.0.0
153
+ * @committed
154
+ */
155
+ auto end(std::tm value) -> date_range_query&;
156
+
157
+ /**
158
+ * Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.
159
+ *
160
+ * @param value end limit time point
161
+ * @param inclusive whether to include limit value into the interval.
162
+ *
163
+ * @return this query for chaining purposes.
164
+ *
165
+ * @since 1.0.0
166
+ * @committed
167
+ */
168
+ auto end(std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query&;
169
+
170
+ /**
171
+ * Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.
172
+ *
173
+ * @param value end limit as a `tm` (broken down timestamp)
174
+ * @param inclusive whether to include limit value into the interval.
175
+ *
176
+ * @return this query for chaining purposes.
177
+ *
178
+ * @since 1.0.0
179
+ * @committed
180
+ */
181
+ auto end(std::tm value, bool inclusive) -> date_range_query&;
182
+
183
+ /**
184
+ * Set preformatted date as upper limit.
185
+ *
186
+ * @param value end limit formatted as a string, use @ref date_time_parser() for non-standard formats
187
+ *
188
+ * @return this query for chaining purposes.
189
+ *
190
+ * @since 1.0.0
191
+ * @committed
192
+ */
193
+ auto end(std::string value)
194
+ {
195
+ end_ = std::move(value);
196
+ return *this;
197
+ }
198
+
199
+ /**
200
+ * Set preformatted date as upper limit.
201
+ *
202
+ * @param value end limit formatted as a string, use @ref date_time_parser() for non-standard formats
203
+ * @param inclusive whether to include limit value into the interval.
204
+ *
205
+ * @return this query for chaining purposes.
206
+ *
207
+ * @since 1.0.0
208
+ * @committed
209
+ */
210
+ auto end(std::string value, bool inclusive) -> date_range_query&
211
+ {
212
+ end_ = std::move(value);
213
+ inclusive_end_ = inclusive;
214
+ return *this;
215
+ }
216
+
217
+ /**
218
+ * Enable custom date parser.
219
+ *
220
+ * @param parser_name name of the custom date parser
221
+ *
222
+ * @return this query for chaining purposes.
223
+ *
224
+ * @since 1.0.0
225
+ * @committed
226
+ */
227
+ auto date_time_parser(std::string parser_name) -> date_range_query&
228
+ {
229
+ date_time_parser_ = std::move(parser_name);
230
+ return *this;
231
+ }
232
+
233
+ /**
234
+ * If a field is specified, only terms in that field will be matched.
235
+ *
236
+ * @param field_name name of the field to be matched
237
+ *
238
+ * @return this query for chaining purposes.
239
+ *
240
+ * @since 1.0.0
241
+ * @committed
242
+ */
243
+ auto field(std::string field_name) -> date_range_query&
244
+ {
245
+ field_ = std::move(field_name);
246
+ return *this;
247
+ }
248
+
249
+ /**
250
+ * @return encoded representation of the query.
251
+ *
252
+ * @since 1.0.0
253
+ * @internal
254
+ */
255
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
256
+
257
+ private:
258
+ std::optional<std::string> start_{};
259
+ std::optional<std::string> end_{};
260
+ std::optional<bool> inclusive_start_{};
261
+ std::optional<bool> inclusive_end_{};
262
+ std::optional<std::string> date_time_parser_{};
263
+ std::optional<std::string> field_{};
264
+ };
265
+ } // namespace couchbase
@@ -0,0 +1,109 @@
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 <cstdint>
23
+ #include <memory>
24
+ #include <vector>
25
+
26
+ namespace couchbase
27
+ {
28
+ /**
29
+ * The disjunction query is a compound query. The result documents must satisfy a configurable minimal (@ref min) number of child queries.
30
+ * By default this min is set to 1.
31
+ *
32
+ * At execution, a conjunction query that has no child queries is not allowed and will fail fast.
33
+ *
34
+ * Match documents with at least one (see @ref min) of the following conditions is satisfied:
35
+ * * `"location"` in the field `reviews.content`
36
+ * * `true` in the field `free_breakfast`.
37
+ *
38
+ * @snippet test_unit_search.cxx search-disjunction
39
+ *
40
+ * @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-conjuncts-disjuncts.html server documentation
41
+ *
42
+ * @since 1.0.0
43
+ * @committed
44
+ */
45
+ class disjunction_query : public search_query
46
+ {
47
+ public:
48
+ /**
49
+ * Create a disjunction query.
50
+ *
51
+ * @tparam SearchQuery any subclass of @ref search_query
52
+ * @param queries sequence of query arguments
53
+ *
54
+ * @since 1.0.0
55
+ * @committed
56
+ */
57
+ template<typename... SearchQuery>
58
+ explicit disjunction_query(SearchQuery&&... queries)
59
+ {
60
+ or_else(std::forward<SearchQuery>(queries)...);
61
+ }
62
+
63
+ /**
64
+ * Add one or more queries to add to the disjunction.
65
+ *
66
+ * @tparam SearchQuery any subclass of @ref search_query
67
+ * @param queries sequence of query arguments
68
+ *
69
+ * @return this query for chaining purposes.
70
+ *
71
+ * @since 1.0.0
72
+ * @committed
73
+ */
74
+ template<typename... SearchQuery>
75
+ auto or_else(SearchQuery... queries) -> disjunction_query&
76
+ {
77
+ (disjuncts_.emplace_back(std::make_shared<SearchQuery>(std::move(queries))), ...);
78
+ return *this;
79
+ }
80
+
81
+ /**
82
+ * Set the minimum number of child queries that must be satisfied for the disjunction query.
83
+ *
84
+ * @param number_of_queries minimum number of child queries.
85
+ *
86
+ * @return this query for chaining purposes.
87
+ *
88
+ * @since 1.0.0
89
+ * @committed
90
+ */
91
+ auto min(std::uint32_t number_of_queries) -> disjunction_query&
92
+ {
93
+ min_ = number_of_queries;
94
+ return *this;
95
+ }
96
+
97
+ /**
98
+ * @return encoded representation of the query.
99
+ *
100
+ * @since 1.0.0
101
+ * @internal
102
+ */
103
+ [[nodiscard]] auto encode() const -> encoded_search_query override;
104
+
105
+ private:
106
+ std::vector<std::shared_ptr<search_query>> disjuncts_{};
107
+ std::uint32_t min_{ 1 };
108
+ };
109
+ } // namespace couchbase