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.
- package/CMakeLists.txt +136 -11
- package/deps/couchbase-cxx-client/CMakeLists.txt +54 -4
- package/deps/couchbase-cxx-client/README.md +1 -0
- package/deps/couchbase-cxx-client/bin/create-search-index +164 -0
- package/deps/couchbase-cxx-client/bin/init-cluster +55 -10
- package/deps/couchbase-cxx-client/bin/run-unit-tests +62 -6
- package/deps/couchbase-cxx-client/bin/travel-sample-index-v6.json +184 -0
- package/deps/couchbase-cxx-client/bin/travel-sample-index.json +188 -0
- package/deps/couchbase-cxx-client/cmake/Documentation.cmake +0 -1
- package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +98 -3
- package/deps/couchbase-cxx-client/cmake/Testing.cmake +8 -0
- package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +3 -0
- package/deps/couchbase-cxx-client/core/bucket.cxx +183 -152
- package/deps/couchbase-cxx-client/core/bucket.hxx +17 -4
- package/deps/couchbase-cxx-client/core/cluster.hxx +18 -1
- package/deps/couchbase-cxx-client/core/cluster_options.hxx +1 -0
- package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +2 -1
- package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +10 -12
- package/deps/couchbase-cxx-client/core/error_context/search.hxx +1 -1
- package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
- package/deps/couchbase-cxx-client/core/impl/boolean_field_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/impl/boolean_query.cxx +62 -0
- package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -0
- package/deps/couchbase-cxx-client/core/impl/conjunction_query.cxx +51 -0
- package/deps/couchbase-cxx-client/core/impl/date_range.cxx +89 -0
- package/deps/couchbase-cxx-client/core/impl/date_range_facet.cxx +54 -0
- package/deps/couchbase-cxx-client/core/impl/date_range_facet_result.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/date_range_query.cxx +125 -0
- package/deps/couchbase-cxx-client/core/impl/disjunction_query.cxx +51 -0
- package/deps/couchbase-cxx-client/core/impl/encoded_search_facet.hxx +29 -0
- package/deps/couchbase-cxx-client/core/impl/encoded_search_query.hxx +29 -0
- package/deps/couchbase-cxx-client/core/impl/encoded_search_sort.hxx +29 -0
- package/deps/couchbase-cxx-client/core/impl/geo_bounding_box_query.cxx +46 -0
- package/deps/couchbase-cxx-client/core/impl/geo_distance_query.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/geo_polygon_query.cxx +46 -0
- package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.cxx +80 -0
- package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.hxx +48 -0
- package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.cxx +80 -0
- package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.hxx +48 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.cxx +141 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.hxx +61 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.cxx +60 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.hxx +41 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_result.cxx +84 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_result.hxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row.cxx +82 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row.hxx +56 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row_location.hxx +32 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.cxx +137 -0
- package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.hxx +45 -0
- package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.cxx +80 -0
- package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.hxx +48 -0
- package/deps/couchbase-cxx-client/core/impl/key_value_error_context.cxx +98 -0
- package/deps/couchbase-cxx-client/core/impl/match_all_query.cxx +35 -0
- package/deps/couchbase-cxx-client/core/impl/match_none_query.cxx +35 -0
- package/deps/couchbase-cxx-client/core/impl/match_phrase_query.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/match_query.cxx +59 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range.cxx +49 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range_facet.cxx +54 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range_facet_result.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/numeric_range_query.cxx +56 -0
- package/deps/couchbase-cxx-client/core/impl/phrase_query.cxx +42 -0
- package/deps/couchbase-cxx-client/core/impl/prefix_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +75 -0
- package/deps/couchbase-cxx-client/core/impl/query_string_query.cxx +37 -0
- package/deps/couchbase-cxx-client/core/impl/regexp_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/impl/search.cxx +191 -0
- package/deps/couchbase-cxx-client/core/impl/search_error_context.cxx +147 -0
- package/deps/couchbase-cxx-client/core/impl/search_meta_data.cxx +46 -0
- package/deps/couchbase-cxx-client/core/impl/search_result.cxx +66 -0
- package/deps/couchbase-cxx-client/core/impl/search_row.cxx +74 -0
- package/deps/couchbase-cxx-client/core/impl/search_row_location.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/search_row_locations.cxx +66 -0
- package/deps/couchbase-cxx-client/core/impl/search_sort_field.cxx +104 -0
- package/deps/couchbase-cxx-client/core/impl/search_sort_id.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/search_sort_score.cxx +43 -0
- package/deps/couchbase-cxx-client/core/impl/term_facet.cxx +36 -0
- package/deps/couchbase-cxx-client/core/impl/term_facet_result.cxx +64 -0
- package/deps/couchbase-cxx-client/core/impl/term_query.cxx +56 -0
- package/deps/couchbase-cxx-client/core/impl/term_range_query.cxx +57 -0
- package/deps/couchbase-cxx-client/core/impl/wildcard_query.cxx +40 -0
- package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +9 -2
- package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +54 -37
- package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +4 -3
- package/deps/couchbase-cxx-client/core/json_string.hxx +5 -0
- package/deps/couchbase-cxx-client/core/meta/version.cxx +18 -4
- package/deps/couchbase-cxx-client/core/mozilla_ca_bundle.hxx +39 -0
- package/deps/couchbase-cxx-client/core/operations/document_search.cxx +3 -1
- package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -1
- package/deps/couchbase-cxx-client/core/protocol/client_request.hxx +11 -2
- package/deps/couchbase-cxx-client/core/protocol/client_response.hxx +1 -0
- package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +59 -46
- package/deps/couchbase-cxx-client/core/utils/connection_string.hxx +1 -0
- package/deps/couchbase-cxx-client/couchbase/analytics_error_context.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/boolean_field_query.hxx +77 -0
- package/deps/couchbase-cxx-client/couchbase/boolean_query.hxx +223 -0
- package/deps/couchbase-cxx-client/couchbase/cluster.hxx +39 -0
- package/deps/couchbase-cxx-client/couchbase/conjunction_query.hxx +88 -0
- package/deps/couchbase-cxx-client/couchbase/date_range.hxx +69 -0
- package/deps/couchbase-cxx-client/couchbase/date_range_facet.hxx +56 -0
- package/deps/couchbase-cxx-client/couchbase/date_range_facet_result.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/date_range_query.hxx +265 -0
- package/deps/couchbase-cxx-client/couchbase/disjunction_query.hxx +109 -0
- package/deps/couchbase-cxx-client/couchbase/doc_id_query.hxx +111 -0
- package/deps/couchbase-cxx-client/couchbase/error_context.hxx +17 -8
- package/deps/couchbase-cxx-client/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
- package/deps/couchbase-cxx-client/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
- package/deps/couchbase-cxx-client/couchbase/fmt/search_scan_consistency.hxx +49 -0
- package/deps/couchbase-cxx-client/couchbase/geo_bounding_box_query.hxx +107 -0
- package/deps/couchbase-cxx-client/couchbase/geo_distance_query.hxx +109 -0
- package/deps/couchbase-cxx-client/couchbase/geo_point.hxx +32 -0
- package/deps/couchbase-cxx-client/couchbase/geo_polygon_query.hxx +85 -0
- package/deps/couchbase-cxx-client/couchbase/highlight_style.hxx +45 -0
- package/deps/couchbase-cxx-client/couchbase/key_value_error_context.hxx +7 -2
- package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/match_all_query.hxx +43 -0
- package/deps/couchbase-cxx-client/couchbase/match_none_query.hxx +43 -0
- package/deps/couchbase-cxx-client/couchbase/match_operator.hxx +45 -0
- package/deps/couchbase-cxx-client/couchbase/match_phrase_query.hxx +108 -0
- package/deps/couchbase-cxx-client/couchbase/match_query.hxx +163 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range.hxx +58 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range_facet.hxx +56 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range_facet_result.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/numeric_range_query.hxx +143 -0
- package/deps/couchbase-cxx-client/couchbase/phrase_query.hxx +93 -0
- package/deps/couchbase-cxx-client/couchbase/prefix_query.hxx +82 -0
- package/deps/couchbase-cxx-client/couchbase/query_error_context.hxx +3 -1
- package/deps/couchbase-cxx-client/couchbase/query_string_query.hxx +72 -0
- package/deps/couchbase-cxx-client/couchbase/regexp_query.hxx +82 -0
- package/deps/couchbase-cxx-client/couchbase/scope.hxx +39 -0
- package/deps/couchbase-cxx-client/couchbase/search_date_range.hxx +68 -0
- package/deps/couchbase-cxx-client/couchbase/search_error_context.hxx +138 -0
- package/deps/couchbase-cxx-client/couchbase/search_facet.hxx +60 -0
- package/deps/couchbase-cxx-client/couchbase/search_facet_result.hxx +50 -0
- package/deps/couchbase-cxx-client/couchbase/search_meta_data.hxx +85 -0
- package/deps/couchbase-cxx-client/couchbase/search_metrics.hxx +127 -0
- package/deps/couchbase-cxx-client/couchbase/search_numeric_range.hxx +69 -0
- package/deps/couchbase-cxx-client/couchbase/search_options.hxx +509 -0
- package/deps/couchbase-cxx-client/couchbase/search_query.hxx +69 -0
- package/deps/couchbase-cxx-client/couchbase/search_result.hxx +77 -0
- package/deps/couchbase-cxx-client/couchbase/search_row.hxx +104 -0
- package/deps/couchbase-cxx-client/couchbase/search_row_location.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/search_row_locations.hxx +86 -0
- package/deps/couchbase-cxx-client/couchbase/search_scan_consistency.hxx +34 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort.hxx +58 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field.hxx +117 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field_missing.hxx +26 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field_mode.hxx +27 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_field_type.hxx +28 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_id.hxx +60 -0
- package/deps/couchbase-cxx-client/couchbase/search_sort_score.hxx +60 -0
- package/deps/couchbase-cxx-client/couchbase/search_term_range.hxx +51 -0
- package/deps/couchbase-cxx-client/couchbase/security_options.hxx +3 -0
- package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +4 -2
- package/deps/couchbase-cxx-client/couchbase/term_facet.hxx +48 -0
- package/deps/couchbase-cxx-client/couchbase/term_facet_result.hxx +55 -0
- package/deps/couchbase-cxx-client/couchbase/term_query.hxx +151 -0
- package/deps/couchbase-cxx-client/couchbase/term_range_query.hxx +142 -0
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +2 -1
- package/deps/couchbase-cxx-client/couchbase/transactions/transaction_result.hxx +1 -1
- package/deps/couchbase-cxx-client/couchbase/transactions.hxx +3 -3
- package/deps/couchbase-cxx-client/couchbase/wildcard_query.hxx +83 -0
- package/deps/couchbase-cxx-client/docs/Doxyfile.in +1 -1
- package/deps/couchbase-cxx-client/docs/cbc-analytics.md +2 -2
- package/deps/couchbase-cxx-client/docs/cbc-get.md +3 -2
- package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +7 -2
- package/deps/couchbase-cxx-client/docs/cbc-query.md +2 -2
- package/deps/couchbase-cxx-client/docs/cbc.md +3 -3
- package/deps/couchbase-cxx-client/docs/cli.hxx +5 -5
- package/deps/couchbase-cxx-client/docs/mainpage.hxx +42 -5
- package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
- package/deps/couchbase-cxx-client/test/test_integration_analytics.cxx +28 -6
- package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +7 -3
- package/deps/couchbase-cxx-client/test/test_integration_connect.cxx +7 -3
- package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +13 -3
- package/deps/couchbase-cxx-client/test/test_integration_diagnostics.cxx +8 -2
- package/deps/couchbase-cxx-client/test/test_integration_durability.cxx +12 -7
- package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +283 -11
- package/deps/couchbase-cxx-client/test/test_integration_management.cxx +140 -88
- package/deps/couchbase-cxx-client/test/test_integration_query.cxx +67 -9
- package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +12 -12
- package/deps/couchbase-cxx-client/test/test_integration_read_replica.cxx +48 -11
- package/deps/couchbase-cxx-client/test/test_integration_search.cxx +19 -1
- package/deps/couchbase-cxx-client/test/test_integration_subdoc.cxx +60 -9
- package/deps/couchbase-cxx-client/test/test_integration_tracer.cxx +3 -0
- package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +4 -0
- package/deps/couchbase-cxx-client/test/test_transaction_examples.cxx +100 -85
- package/deps/couchbase-cxx-client/test/test_unit_connection_string.cxx +29 -0
- package/deps/couchbase-cxx-client/test/test_unit_search.cxx +427 -0
- package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -1
- package/deps/couchbase-cxx-client/test/utils/logger.cxx +3 -1
- package/deps/couchbase-cxx-client/test/utils/server_version.hxx +31 -15
- package/deps/couchbase-cxx-client/test/utils/test_context.cxx +8 -0
- package/deps/couchbase-cxx-client/tools/get.cxx +9 -8
- package/deps/couchbase-cxx-client/tools/pillowfight.cxx +175 -75
- package/deps/couchbase-cxx-client/tools/version.cxx +4 -2
- package/dist/binding.d.ts +1 -1
- package/dist/binding.js +3 -2
- package/package.json +96 -1
- package/scripts/createPlatformPackages.js +108 -0
- package/scripts/install.js +45 -0
- package/scripts/prebuilds.js +249 -0
- package/scripts/prune.js +124 -0
- package/src/jstocbpp_autogen.hpp +3 -2
|
@@ -0,0 +1,85 @@
|
|
|
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/geo_point.hxx>
|
|
21
|
+
#include <couchbase/search_query.hxx>
|
|
22
|
+
|
|
23
|
+
#include <optional>
|
|
24
|
+
#include <string>
|
|
25
|
+
#include <vector>
|
|
26
|
+
|
|
27
|
+
namespace couchbase
|
|
28
|
+
{
|
|
29
|
+
/**
|
|
30
|
+
* A search query which allows to match inside a geo polygon.
|
|
31
|
+
*
|
|
32
|
+
* If a target data-location falls within the box, its document is returned.
|
|
33
|
+
*
|
|
34
|
+
* @snippet test_unit_search.cxx search-geo-polygon
|
|
35
|
+
*
|
|
36
|
+
* @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-geo-bounded-polygon.html server documentation
|
|
37
|
+
*
|
|
38
|
+
* @since 1.0.0
|
|
39
|
+
* @committed
|
|
40
|
+
*/
|
|
41
|
+
class geo_polygon_query : public search_query
|
|
42
|
+
{
|
|
43
|
+
public:
|
|
44
|
+
/**
|
|
45
|
+
* Create a new geo polygon query.
|
|
46
|
+
*
|
|
47
|
+
* @param points the points specifying corners of geo polygon.
|
|
48
|
+
*
|
|
49
|
+
* @since 1.0.0
|
|
50
|
+
* @committed
|
|
51
|
+
*/
|
|
52
|
+
explicit geo_polygon_query(std::vector<geo_point> points)
|
|
53
|
+
: polygon_points_{ std::move(points) }
|
|
54
|
+
{
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* If a field is specified, only terms in that field will be matched.
|
|
59
|
+
*
|
|
60
|
+
* @param field_name name of the field to be matched
|
|
61
|
+
*
|
|
62
|
+
* @return this query for chaining purposes.
|
|
63
|
+
*
|
|
64
|
+
* @since 1.0.0
|
|
65
|
+
* @committed
|
|
66
|
+
*/
|
|
67
|
+
auto field(std::string field_name) -> geo_polygon_query&
|
|
68
|
+
{
|
|
69
|
+
field_ = std::move(field_name);
|
|
70
|
+
return *this;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @return encoded representation of the query.
|
|
75
|
+
*
|
|
76
|
+
* @since 1.0.0
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
[[nodiscard]] auto encode() const -> encoded_search_query override;
|
|
80
|
+
|
|
81
|
+
private:
|
|
82
|
+
std::vector<geo_point> polygon_points_;
|
|
83
|
+
std::optional<std::string> field_{};
|
|
84
|
+
};
|
|
85
|
+
} // namespace couchbase
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
namespace couchbase
|
|
21
|
+
{
|
|
22
|
+
/**
|
|
23
|
+
* Enumeration of the highlighting styles recognized by the FTS engine.
|
|
24
|
+
*
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
* @committed
|
|
27
|
+
*/
|
|
28
|
+
enum class highlight_style {
|
|
29
|
+
/**
|
|
30
|
+
* Use HTML tags `<mark>` and `</mark>` to indicate matches in the fields.
|
|
31
|
+
*
|
|
32
|
+
* @since 1.0.0
|
|
33
|
+
* @committed
|
|
34
|
+
*/
|
|
35
|
+
html,
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Use ANSI code sequences `\\x1b[43m>` and `\\x1b[0m` to indicate matches in the fields.
|
|
39
|
+
*
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
* @committed
|
|
42
|
+
*/
|
|
43
|
+
ansi,
|
|
44
|
+
};
|
|
45
|
+
} // namespace couchbase
|
|
@@ -48,6 +48,7 @@ class key_value_error_context : public error_context
|
|
|
48
48
|
/**
|
|
49
49
|
* Creates and initializes error context with given parameters.
|
|
50
50
|
*
|
|
51
|
+
* @param operation_id
|
|
51
52
|
* @param ec
|
|
52
53
|
* @param last_dispatched_to
|
|
53
54
|
* @param last_dispatched_from
|
|
@@ -66,7 +67,8 @@ class key_value_error_context : public error_context
|
|
|
66
67
|
* @since 1.0.0
|
|
67
68
|
* @internal
|
|
68
69
|
*/
|
|
69
|
-
key_value_error_context(std::
|
|
70
|
+
key_value_error_context(std::string operation_id,
|
|
71
|
+
std::error_code ec,
|
|
70
72
|
std::optional<std::string> last_dispatched_to,
|
|
71
73
|
std::optional<std::string> last_dispatched_from,
|
|
72
74
|
std::size_t retry_attempts,
|
|
@@ -80,7 +82,8 @@ class key_value_error_context : public error_context
|
|
|
80
82
|
couchbase::cas cas,
|
|
81
83
|
std::optional<key_value_error_map_info> error_map_info,
|
|
82
84
|
std::optional<key_value_extended_error_info> extended_error_info)
|
|
83
|
-
: error_context{ ec, std::move(last_dispatched_to), std::move(last_dispatched_from), retry_attempts,
|
|
85
|
+
: error_context{ std::move(operation_id), ec, std::move(last_dispatched_to), std::move(last_dispatched_from), retry_attempts,
|
|
86
|
+
std::move(retry_reasons) }
|
|
84
87
|
, id_{ std::move(id) }
|
|
85
88
|
, bucket_{ std::move(bucket) }
|
|
86
89
|
, scope_{ std::move(scope) }
|
|
@@ -210,6 +213,8 @@ class key_value_error_context : public error_context
|
|
|
210
213
|
return extended_error_info_;
|
|
211
214
|
}
|
|
212
215
|
|
|
216
|
+
[[nodiscard]] auto to_json() const -> std::string;
|
|
217
|
+
|
|
213
218
|
private:
|
|
214
219
|
std::string id_{};
|
|
215
220
|
std::string bucket_{};
|
|
@@ -67,7 +67,7 @@ class manager_error_context : public error_context
|
|
|
67
67
|
std::uint32_t http_status,
|
|
68
68
|
std::string content,
|
|
69
69
|
std::string path)
|
|
70
|
-
: error_context{ ec, std::move(last_dispatched_to), std::move(last_dispatched_from), retry_attempts, std::move(retry_reasons) }
|
|
70
|
+
: error_context{ {}, ec, std::move(last_dispatched_to), std::move(last_dispatched_from), retry_attempts, std::move(retry_reasons) }
|
|
71
71
|
, client_context_id_{ std::move(client_context_id) }
|
|
72
72
|
, http_status_{ http_status }
|
|
73
73
|
, content_{ std::move(content) }
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
namespace couchbase
|
|
23
|
+
{
|
|
24
|
+
/**
|
|
25
|
+
* A query that matches all indexed documents.
|
|
26
|
+
*
|
|
27
|
+
* @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-match-all.html server documentation
|
|
28
|
+
*
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
* @committed
|
|
31
|
+
*/
|
|
32
|
+
class match_all_query : public search_query
|
|
33
|
+
{
|
|
34
|
+
public:
|
|
35
|
+
/**
|
|
36
|
+
* @return encoded representation of the query.
|
|
37
|
+
*
|
|
38
|
+
* @since 1.0.0
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
[[nodiscard]] auto encode() const -> encoded_search_query override;
|
|
42
|
+
};
|
|
43
|
+
} // namespace couchbase
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
namespace couchbase
|
|
23
|
+
{
|
|
24
|
+
/**
|
|
25
|
+
* A query that matches nothing.
|
|
26
|
+
*
|
|
27
|
+
* @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-match-none.html server documentation
|
|
28
|
+
*
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
* @committed
|
|
31
|
+
*/
|
|
32
|
+
class match_none_query : public search_query
|
|
33
|
+
{
|
|
34
|
+
public:
|
|
35
|
+
/**
|
|
36
|
+
* @return encoded representation of the query.
|
|
37
|
+
*
|
|
38
|
+
* @since 1.0.0
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
[[nodiscard]] auto encode() const -> encoded_search_query override;
|
|
42
|
+
};
|
|
43
|
+
} // namespace couchbase
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
/**
|
|
23
|
+
* Defines how the individual match terms should be logically concatenated
|
|
24
|
+
*
|
|
25
|
+
* @since 1.0.0
|
|
26
|
+
* @committed
|
|
27
|
+
*/
|
|
28
|
+
enum class match_operator {
|
|
29
|
+
/**
|
|
30
|
+
* Individual match terms are concatenated with a logical OR - this is the default if not provided.
|
|
31
|
+
*
|
|
32
|
+
* @since 1.0.0
|
|
33
|
+
* @committed
|
|
34
|
+
*/
|
|
35
|
+
logical_or,
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Individual match terms are concatenated with a logical AND.
|
|
39
|
+
*
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
* @committed
|
|
42
|
+
*/
|
|
43
|
+
logical_and,
|
|
44
|
+
};
|
|
45
|
+
} // namespace couchbase
|
|
@@ -0,0 +1,108 @@
|
|
|
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 input text is analyzed and a phrase query is built with the terms resulting from the analysis. This type of query searches for terms
|
|
29
|
+
* occurring in the specified positions and offsets. This depends on term vectors, which are consulted to determine phrase distance.
|
|
30
|
+
*
|
|
31
|
+
* For example, a match phrase query for `"location for functions"` is matched with `"locate the function"`, if the standard analyzer is
|
|
32
|
+
* used: this analyzer uses a **stemmer**, which tokenizes `"location"` and `"locate"` to `"locat"`, and reduces `"functions"` and
|
|
33
|
+
* `"function"` to `"function"`. Additionally, the analyzer employs stop removal, which removes small and less significant words from input
|
|
34
|
+
* and target text, so that matches are attempted on only the more significant elements of vocabulary: in this case `"for"` and `"the"` are
|
|
35
|
+
* removed. Following this processing, the tokens `"locat"` and `"function"` are recognized as common to both input and target; and also as
|
|
36
|
+
* being both in the same sequence as, and at the same distance from one another; and therefore a match is made.
|
|
37
|
+
* @snippet test_unit_search.cxx search-match-phrase
|
|
38
|
+
*
|
|
39
|
+
* @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-match-phrase.html
|
|
40
|
+
*
|
|
41
|
+
* @since 1.0.0
|
|
42
|
+
* @committed
|
|
43
|
+
*/
|
|
44
|
+
class match_phrase_query : public search_query
|
|
45
|
+
{
|
|
46
|
+
public:
|
|
47
|
+
/**
|
|
48
|
+
* Create a new match phrase query.
|
|
49
|
+
*
|
|
50
|
+
* @param match_phrase the input string to be matched against
|
|
51
|
+
*
|
|
52
|
+
* @since 1.0.0
|
|
53
|
+
* @committed
|
|
54
|
+
*/
|
|
55
|
+
explicit match_phrase_query(std::string match_phrase)
|
|
56
|
+
: match_phrase_{ std::move(match_phrase) }
|
|
57
|
+
{
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Analyzers are used to transform input text into a stream of tokens for indexing. The Server comes with built-in analyzers and the
|
|
62
|
+
* users can create their own.
|
|
63
|
+
*
|
|
64
|
+
* @param analyzer_name the name of the analyzer used
|
|
65
|
+
*
|
|
66
|
+
* @return this query for chaining purposes.
|
|
67
|
+
*
|
|
68
|
+
* @since 1.0.0
|
|
69
|
+
* @committed
|
|
70
|
+
*/
|
|
71
|
+
auto analyzer(std::string analyzer_name) -> match_phrase_query&
|
|
72
|
+
{
|
|
73
|
+
analyzer_ = std::move(analyzer_name);
|
|
74
|
+
return *this;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* If a field is specified, only terms in that field will be matched.
|
|
79
|
+
*
|
|
80
|
+
* This can also affect the used analyzer if one isn't specified explicitly.
|
|
81
|
+
*
|
|
82
|
+
* @param field_name name of the field to be matched
|
|
83
|
+
*
|
|
84
|
+
* @return this query for chaining purposes.
|
|
85
|
+
*
|
|
86
|
+
* @since 1.0.0
|
|
87
|
+
* @committed
|
|
88
|
+
*/
|
|
89
|
+
auto field(std::string field_name) -> match_phrase_query&
|
|
90
|
+
{
|
|
91
|
+
field_ = std::move(field_name);
|
|
92
|
+
return *this;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @return encoded representation of the query.
|
|
97
|
+
*
|
|
98
|
+
* @since 1.0.0
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
[[nodiscard]] auto encode() const -> encoded_search_query override;
|
|
102
|
+
|
|
103
|
+
private:
|
|
104
|
+
std::string match_phrase_;
|
|
105
|
+
std::optional<std::string> analyzer_{};
|
|
106
|
+
std::optional<std::string> field_{};
|
|
107
|
+
};
|
|
108
|
+
} // namespace couchbase
|
|
@@ -0,0 +1,163 @@
|
|
|
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 <stdexcept>
|
|
26
|
+
#include <string>
|
|
27
|
+
|
|
28
|
+
namespace couchbase
|
|
29
|
+
{
|
|
30
|
+
/**
|
|
31
|
+
* A match query analyzes the input text and uses that analyzed text to query the index. An attempt is made to use the same analyzer that
|
|
32
|
+
* was used when the field was indexed.
|
|
33
|
+
*
|
|
34
|
+
* Match documents with both `"location"` and `"hostel"` terms in the field `reviews.content`, ensuring common prefix length `4`, maximum
|
|
35
|
+
* fuzziness and select standard analyzer.
|
|
36
|
+
* @snippet test_unit_search.cxx search-match
|
|
37
|
+
*
|
|
38
|
+
* @see https://docs.couchbase.com/server/current/fts/fts-supported-queries-match.html server documentation
|
|
39
|
+
*
|
|
40
|
+
* @since 1.0.0
|
|
41
|
+
* @committed
|
|
42
|
+
*/
|
|
43
|
+
class match_query : public search_query
|
|
44
|
+
{
|
|
45
|
+
public:
|
|
46
|
+
/**
|
|
47
|
+
* Create a new match query.
|
|
48
|
+
*
|
|
49
|
+
* @param match the input string to be matched against
|
|
50
|
+
*
|
|
51
|
+
* @since 1.0.0
|
|
52
|
+
* @committed
|
|
53
|
+
*/
|
|
54
|
+
explicit match_query(std::string match)
|
|
55
|
+
: match_{ std::move(match) }
|
|
56
|
+
{
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Require that the term also have the same prefix of the specified length (must be positive).
|
|
61
|
+
*
|
|
62
|
+
* @param length the length of the term prefix
|
|
63
|
+
*
|
|
64
|
+
* @return this query for chaining purposes.
|
|
65
|
+
*
|
|
66
|
+
* @since 1.0.0
|
|
67
|
+
* @committed
|
|
68
|
+
*/
|
|
69
|
+
auto prefix_length(std::uint32_t length) -> match_query&
|
|
70
|
+
{
|
|
71
|
+
if (length <= 0) {
|
|
72
|
+
throw std::invalid_argument("prefix_length must be positive");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
prefix_length_ = length;
|
|
76
|
+
return *this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Analyzers are used to transform input text into a stream of tokens for indexing. The Server comes with built-in analyzers and the
|
|
81
|
+
* users can create their own.
|
|
82
|
+
*
|
|
83
|
+
* @param analyzer_name the name of the analyzer used
|
|
84
|
+
*
|
|
85
|
+
* @return this query for chaining purposes.
|
|
86
|
+
*
|
|
87
|
+
* @since 1.0.0
|
|
88
|
+
* @committed
|
|
89
|
+
*/
|
|
90
|
+
auto analyzer(std::string analyzer_name) -> match_query&
|
|
91
|
+
{
|
|
92
|
+
analyzer_ = std::move(analyzer_name);
|
|
93
|
+
return *this;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* If a field is specified, only terms in that field will be matched.
|
|
98
|
+
*
|
|
99
|
+
* This can also affect the used analyzer if one isn't specified explicitly.
|
|
100
|
+
*
|
|
101
|
+
* @param field_name name of the field to be matched
|
|
102
|
+
*
|
|
103
|
+
* @return this query for chaining purposes.
|
|
104
|
+
*
|
|
105
|
+
* @since 1.0.0
|
|
106
|
+
* @committed
|
|
107
|
+
*/
|
|
108
|
+
auto field(std::string field_name) -> match_query&
|
|
109
|
+
{
|
|
110
|
+
field_ = std::move(field_name);
|
|
111
|
+
return *this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Perform fuzzy matching. If the fuzziness parameter is set to a non-zero integer the analyzed text will be matched with the specified
|
|
116
|
+
* level of fuzziness.
|
|
117
|
+
*
|
|
118
|
+
* @param fuzziness level of fuzziness (the maximum supported fuzziness is 2).
|
|
119
|
+
*
|
|
120
|
+
* @return this query for chaining purposes.
|
|
121
|
+
*
|
|
122
|
+
* @since 1.0.0
|
|
123
|
+
* @committed
|
|
124
|
+
*/
|
|
125
|
+
auto fuzziness(std::uint32_t fuzziness) -> match_query&
|
|
126
|
+
{
|
|
127
|
+
fuzziness_ = fuzziness;
|
|
128
|
+
return *this;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Defines how the individual match terms should be logically concatenated
|
|
133
|
+
*
|
|
134
|
+
* @param concatenation_operator operator to be used
|
|
135
|
+
*
|
|
136
|
+
* @return this query for chaining purposes.
|
|
137
|
+
*
|
|
138
|
+
* @since 1.0.0
|
|
139
|
+
* @committed
|
|
140
|
+
*/
|
|
141
|
+
auto match_operator(couchbase::match_operator concatenation_operator) -> match_query&
|
|
142
|
+
{
|
|
143
|
+
operator_ = concatenation_operator;
|
|
144
|
+
return *this;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @return encoded representation of the query.
|
|
149
|
+
*
|
|
150
|
+
* @since 1.0.0
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
153
|
+
[[nodiscard]] auto encode() const -> encoded_search_query override;
|
|
154
|
+
|
|
155
|
+
private:
|
|
156
|
+
std::string match_;
|
|
157
|
+
std::optional<std::uint32_t> prefix_length_{};
|
|
158
|
+
std::optional<std::string> analyzer_{};
|
|
159
|
+
std::optional<std::string> field_{};
|
|
160
|
+
std::optional<std::uint32_t> fuzziness_{};
|
|
161
|
+
std::optional<couchbase::match_operator> operator_{};
|
|
162
|
+
};
|
|
163
|
+
} // 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
|
+
#include <cstdint>
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
namespace couchbase
|
|
25
|
+
{
|
|
26
|
+
/**
|
|
27
|
+
* Numeric range for @ref numeric_range_facet.
|
|
28
|
+
*/
|
|
29
|
+
class numeric_range
|
|
30
|
+
{
|
|
31
|
+
public:
|
|
32
|
+
numeric_range(std::string name, double min, double max);
|
|
33
|
+
static numeric_range with_min(std::string name, double start);
|
|
34
|
+
static numeric_range with_max(std::string name, double end);
|
|
35
|
+
|
|
36
|
+
[[nodiscard]] auto name() const -> const std::string&
|
|
37
|
+
{
|
|
38
|
+
return name_;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[[nodiscard]] auto min() const -> const std::optional<double>&
|
|
42
|
+
{
|
|
43
|
+
return min_;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[[nodiscard]] auto max() const -> const std::optional<double>&
|
|
47
|
+
{
|
|
48
|
+
return max_;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private:
|
|
52
|
+
numeric_range(std::string name, std::optional<double> min, std::optional<double> max);
|
|
53
|
+
|
|
54
|
+
std::string name_;
|
|
55
|
+
std::optional<double> min_{};
|
|
56
|
+
std::optional<double> max_{};
|
|
57
|
+
};
|
|
58
|
+
} // 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/numeric_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 numerical ranges (or buckets) provided by the user.
|
|
29
|
+
*/
|
|
30
|
+
class numeric_range_facet : public search_facet
|
|
31
|
+
{
|
|
32
|
+
public:
|
|
33
|
+
numeric_range_facet(std::string field, std::vector<numeric_range> ranges)
|
|
34
|
+
: search_facet{ std::move(field) }
|
|
35
|
+
, ranges_{ std::move(ranges) }
|
|
36
|
+
{
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
numeric_range_facet(std::string field, std::uint32_t size, std::vector<numeric_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<numeric_range> ranges_;
|
|
55
|
+
};
|
|
56
|
+
} // namespace couchbase
|