couchbase 4.2.9 → 4.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. package/deps/couchbase-cxx-client/CMakeLists.txt +4 -0
  2. package/deps/couchbase-cxx-client/cmake/CompilerWarnings.cmake +7 -3
  3. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +1 -0
  4. package/deps/couchbase-cxx-client/core/bucket.cxx +52 -2
  5. package/deps/couchbase-cxx-client/core/bucket.hxx +1 -1
  6. package/deps/couchbase-cxx-client/core/cluster.cxx +38 -0
  7. package/deps/couchbase-cxx-client/core/impl/bucket.cxx +24 -0
  8. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +73 -0
  9. package/deps/couchbase-cxx-client/core/impl/diagnostics.cxx +294 -0
  10. package/deps/couchbase-cxx-client/core/impl/diagnostics.hxx +39 -0
  11. package/deps/couchbase-cxx-client/core/impl/scope.cxx +19 -4
  12. package/deps/couchbase-cxx-client/core/impl/search.cxx +75 -2
  13. package/deps/couchbase-cxx-client/core/impl/search.hxx +8 -0
  14. package/deps/couchbase-cxx-client/core/impl/search_index_manager.cxx +261 -18
  15. package/deps/couchbase-cxx-client/core/impl/search_request.cxx +139 -0
  16. package/deps/couchbase-cxx-client/core/impl/vector_query.cxx +42 -0
  17. package/deps/couchbase-cxx-client/core/impl/vector_search.cxx +40 -0
  18. package/deps/couchbase-cxx-client/core/io/http_session.hxx +6 -3
  19. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +24 -32
  20. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +1 -0
  21. package/deps/couchbase-cxx-client/core/logger/logger.cxx +1 -1
  22. package/deps/couchbase-cxx-client/core/meta/features.hxx +10 -0
  23. package/deps/couchbase-cxx-client/core/operations/document_query.cxx +6 -1
  24. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +37 -1
  25. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +11 -0
  26. package/deps/couchbase-cxx-client/core/operations/management/collection_create.cxx +7 -6
  27. package/deps/couchbase-cxx-client/core/operations/management/collection_create.hxx +1 -1
  28. package/deps/couchbase-cxx-client/core/operations/management/collection_update.cxx +7 -8
  29. package/deps/couchbase-cxx-client/core/operations/management/collection_update.hxx +1 -1
  30. package/deps/couchbase-cxx-client/core/operations/management/error_utils.cxx +3 -0
  31. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.cxx +17 -1
  32. package/deps/couchbase-cxx-client/core/operations/management/search_index_analyze_document.hxx +3 -0
  33. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.cxx +21 -1
  34. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_ingest.hxx +3 -0
  35. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.cxx +21 -1
  36. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_plan_freeze.hxx +3 -0
  37. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.cxx +21 -1
  38. package/deps/couchbase-cxx-client/core/operations/management/search_index_control_query.hxx +3 -0
  39. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.cxx +17 -1
  40. package/deps/couchbase-cxx-client/core/operations/management/search_index_drop.hxx +3 -0
  41. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.cxx +17 -1
  42. package/deps/couchbase-cxx-client/core/operations/management/search_index_get.hxx +2 -0
  43. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.cxx +39 -22
  44. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_all.hxx +3 -0
  45. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.cxx +18 -1
  46. package/deps/couchbase-cxx-client/core/operations/management/search_index_get_documents_count.hxx +3 -0
  47. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.cxx +17 -1
  48. package/deps/couchbase-cxx-client/core/operations/management/search_index_upsert.hxx +3 -0
  49. package/deps/couchbase-cxx-client/core/topology/collections_manifest.hxx +1 -1
  50. package/deps/couchbase-cxx-client/core/topology/collections_manifest_json.hxx +1 -1
  51. package/deps/couchbase-cxx-client/core/transactions/internal/utils.hxx +4 -0
  52. package/deps/couchbase-cxx-client/core/vector_query_combination.hxx +23 -0
  53. package/deps/couchbase-cxx-client/couchbase/bucket.hxx +29 -0
  54. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +110 -0
  55. package/deps/couchbase-cxx-client/couchbase/codec/json_transcoder.hxx +1 -1
  56. package/deps/couchbase-cxx-client/couchbase/codec/raw_binary_transcoder.hxx +2 -1
  57. package/deps/couchbase-cxx-client/couchbase/codec/raw_json_transcoder.hxx +78 -0
  58. package/deps/couchbase-cxx-client/couchbase/codec/raw_string_transcoder.hxx +72 -0
  59. package/deps/couchbase-cxx-client/couchbase/create_collection_options.hxx +29 -1
  60. package/deps/couchbase-cxx-client/couchbase/diagnostics_options.hxx +75 -0
  61. package/deps/couchbase-cxx-client/couchbase/diagnostics_result.hxx +124 -0
  62. package/deps/couchbase-cxx-client/couchbase/endpoint_diagnostics.hxx +206 -0
  63. package/deps/couchbase-cxx-client/couchbase/endpoint_ping_report.hxx +205 -0
  64. package/deps/couchbase-cxx-client/couchbase/get_options.hxx +1 -6
  65. package/deps/couchbase-cxx-client/couchbase/management/collection_spec.hxx +1 -1
  66. package/deps/couchbase-cxx-client/couchbase/ping_options.hxx +93 -0
  67. package/deps/couchbase-cxx-client/couchbase/ping_result.hxx +118 -0
  68. package/deps/couchbase-cxx-client/couchbase/scope.hxx +24 -8
  69. package/deps/couchbase-cxx-client/couchbase/scope_search_index_manager.hxx +291 -0
  70. package/deps/couchbase-cxx-client/couchbase/search_request.hxx +120 -0
  71. package/deps/couchbase-cxx-client/couchbase/service_type.hxx +58 -0
  72. package/deps/couchbase-cxx-client/couchbase/update_collection_options.hxx +32 -3
  73. package/deps/couchbase-cxx-client/couchbase/vector_query.hxx +99 -0
  74. package/deps/couchbase-cxx-client/couchbase/vector_search.hxx +85 -0
  75. package/deps/couchbase-cxx-client/couchbase/vector_search_options.hxx +76 -0
  76. package/dist/binding.d.ts +9 -0
  77. package/dist/binding.js +4 -1
  78. package/dist/bindingutilities.d.ts +6 -1
  79. package/dist/bindingutilities.js +15 -1
  80. package/dist/cluster.d.ts +12 -1
  81. package/dist/cluster.js +22 -0
  82. package/dist/couchbase.d.ts +1 -0
  83. package/dist/couchbase.js +1 -0
  84. package/dist/searchexecutor.d.ts +2 -2
  85. package/dist/searchexecutor.js +19 -3
  86. package/dist/searchtypes.d.ts +46 -0
  87. package/dist/searchtypes.js +81 -1
  88. package/dist/vectorsearch.d.ts +99 -0
  89. package/dist/vectorsearch.js +132 -0
  90. package/package.json +7 -7
  91. package/src/constants.cpp +11 -0
  92. package/src/jstocbpp_autogen.hpp +24 -7
  93. package/tools/gen-bindings-json.py +2 -0
@@ -0,0 +1,99 @@
1
+ #include <utility>
2
+
3
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
4
+ /*
5
+ * Copyright 2023-Present Couchbase, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ #pragma once
21
+
22
+ namespace couchbase
23
+ {
24
+ /**
25
+ * @since 1.0.0
26
+ * @volatile
27
+ */
28
+ class vector_query
29
+ {
30
+ public:
31
+ /**
32
+ * Creates a vector query
33
+ *
34
+ * @param vector_field_name the document field that contains the vector
35
+ * @param vector_query the vector query to run. Cannot be empty.
36
+ *
37
+ * @since 1.0.0
38
+ * @volatile
39
+ */
40
+ vector_query(std::string vector_field_name, std::vector<double> vector_query)
41
+ : vector_field_name_{ std::move(vector_field_name) }
42
+ , vector_query_{ std::move(vector_query) }
43
+ {
44
+ if (vector_query_.empty()) {
45
+ throw std::invalid_argument("the vector_query cannot be empty");
46
+ }
47
+ }
48
+
49
+ /**
50
+ * The number of results that will be returned from this vector query. Defaults to 3.
51
+ *
52
+ * @param num_candidates the number of results returned
53
+ *
54
+ * @return this vector_query for chaining purposes
55
+ *
56
+ * @since 1.0.0
57
+ * @volatile
58
+ */
59
+ auto num_candidates(std::uint32_t num_candidates) -> vector_query&
60
+ {
61
+ if (num_candidates < 1) {
62
+ throw std::invalid_argument("The num_candidates cannot be less than 1");
63
+ }
64
+ num_candidates_ = num_candidates;
65
+ return *this;
66
+ }
67
+
68
+ /**
69
+ * The boost parameter is used to increase the relative weight of a clause (with a boost greater than 1) or decrease the relative weight
70
+ * (with a boost between 0 and 1).
71
+ *
72
+ * @param boost boost value
73
+ *
74
+ * @return this vector_query for chaining purposes.
75
+ *
76
+ * @since 1.0.0
77
+ * @volatile
78
+ */
79
+ auto boost(double boost) -> vector_query&
80
+ {
81
+ boost_ = boost;
82
+ return *this;
83
+ }
84
+
85
+ /**
86
+ * @return encoded representation of the query.
87
+ *
88
+ * @since 1.0.0
89
+ * @internal
90
+ */
91
+ [[nodiscard]] auto encode() const -> encoded_search_query;
92
+
93
+ private:
94
+ std::string vector_field_name_;
95
+ std::vector<double> vector_query_;
96
+ std::uint32_t num_candidates_{ 3 };
97
+ std::optional<double> boost_{};
98
+ };
99
+ } // namespace couchbase
@@ -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/vector_query.hxx>
21
+ #include <couchbase/vector_search_options.hxx>
22
+
23
+ namespace couchbase
24
+ {
25
+ /**
26
+ * A vector_search allows one or more @ref vector_query to be executed.
27
+ *
28
+ * @since 1.0.0
29
+ * @volatile
30
+ */
31
+ class vector_search
32
+ {
33
+ public:
34
+ /**
35
+ * Will execute all of the provided vector_queries, using the specified options
36
+ *
37
+ * @param vector_queries vector queries to be run
38
+ * @param options options to use on the vector queries
39
+ *
40
+ * @since 1.0.0
41
+ * @volatile
42
+ */
43
+ explicit vector_search(std::vector<vector_query> vector_queries, vector_search_options options = {})
44
+ : vector_queries_{ std::move(vector_queries) }
45
+ , options_{ options.build() }
46
+ {
47
+ }
48
+
49
+ /**
50
+ * Will execute a singe vector_query, using default options
51
+ *
52
+ * @param query the query to be run
53
+ *
54
+ * @since 1.0.0
55
+ * @volatile
56
+ */
57
+ explicit vector_search(vector_query query)
58
+ : vector_queries_{ std::vector<vector_query>{ std::move(query) } }
59
+ {
60
+ }
61
+
62
+ /**
63
+ * Fetches the vector_search_options
64
+ *
65
+ * @since 1.0.0
66
+ * @internal
67
+ */
68
+ [[nodiscard]] vector_search_options::built options() const
69
+ {
70
+ return options_;
71
+ }
72
+
73
+ /**
74
+ * @return encoded representation of the vector_search.
75
+ *
76
+ * @since 1.0.0
77
+ * @internal
78
+ */
79
+ [[nodiscard]] auto encode() const -> encoded_search_query;
80
+
81
+ private:
82
+ std::vector<vector_query> vector_queries_;
83
+ vector_search_options::built options_{};
84
+ };
85
+ } // namespace couchbase
@@ -0,0 +1,76 @@
1
+ /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright 2023-Present Couchbase, Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ #pragma once
19
+
20
+ namespace couchbase
21
+ {
22
+ enum class vector_query_combination { combination_and, combination_or };
23
+
24
+ /**
25
+ * Options related to executing a @ref vector_search
26
+ *
27
+ * @since 1.0.0
28
+ * @volatile
29
+ */
30
+ struct vector_search_options {
31
+
32
+ /**
33
+ * Immutable value object representing consistent options
34
+ *
35
+ * @since 1.0.0
36
+ * @internal
37
+ */
38
+ struct built {
39
+ std::optional<vector_query_combination> combination;
40
+ };
41
+
42
+ /**
43
+ * Validates options and returns them as an immutable value.
44
+ *
45
+ * @return consistent options as an immutable value
46
+ *
47
+ * @exception std::system_error with code errc::common::invalid_argument if the options are not valid
48
+ *
49
+ * @since 1.0.0
50
+ * @internal
51
+ */
52
+ [[nodiscard]] auto build() const -> built
53
+ {
54
+ return { combination_ };
55
+ }
56
+
57
+ /**
58
+ * Sets how the vector query results are combined.
59
+ *
60
+ * @param combination @ref vector_query_combination
61
+ * @return this for chaining purposes
62
+ *
63
+ * @since 1.0.0
64
+ * @volatile
65
+ *
66
+ */
67
+ auto query_combination(vector_query_combination combination) -> vector_search_options&
68
+ {
69
+ combination_ = combination;
70
+ return *this;
71
+ }
72
+
73
+ private:
74
+ std::optional<vector_query_combination> combination_{};
75
+ };
76
+ } // namespace couchbase
package/dist/binding.d.ts CHANGED
@@ -131,6 +131,8 @@ export declare enum CppPersistTo {
131
131
  }
132
132
  export declare enum CppReplicateTo {
133
133
  }
134
+ export declare enum CppVectorQueryCombination {
135
+ }
134
136
  export interface CppManagementAnalyticsDataset {
135
137
  name: string;
136
138
  dataverse_name: string;
@@ -858,6 +860,9 @@ export interface CppSearchResponseSearchFacetNumericRangeFacet {
858
860
  export interface CppSearchRequest {
859
861
  index_name: string;
860
862
  query: CppJsonString;
863
+ show_request?: boolean;
864
+ vector_search?: CppJsonString;
865
+ vector_query_combination?: CppVectorQueryCombination;
861
866
  limit?: number;
862
867
  skip?: number;
863
868
  explain?: boolean;
@@ -2461,6 +2466,10 @@ export interface CppBindingAutogen {
2461
2466
  two: CppReplicateTo;
2462
2467
  three: CppReplicateTo;
2463
2468
  };
2469
+ vector_query_combination: {
2470
+ combination_and: CppVectorQueryCombination;
2471
+ combination_or: CppVectorQueryCombination;
2472
+ };
2464
2473
  }
2465
2474
  export type CppErrc = CppErrcCommon | CppErrcKeyValue | CppErrcQuery | CppErrcAnalytics | CppErrcSearch | CppErrcView | CppErrcManagement | CppErrcFieldLevelEncryption | CppErrcNetwork;
2466
2475
  export declare enum CppTxnFailureType {
package/dist/binding.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CppTxnExternalException = exports.CppTxnFailureType = exports.CppReplicateTo = exports.CppPersistTo = exports.CppStoreSemantics = exports.CppImplSubdocOpcode = exports.CppKeyValueStatusCode = exports.CppErrcNetwork = exports.CppErrcFieldLevelEncryption = exports.CppErrcManagement = exports.CppErrcView = exports.CppErrcSearch = exports.CppErrcAnalytics = exports.CppErrcQuery = exports.CppErrcKeyValue = exports.CppErrcCommon = exports.CppDurabilityLevel = exports.CppAnalyticsResponseAnalyticsStatus = exports.CppViewSortOrder = exports.CppViewScanConsistency = exports.CppViewOnError = exports.CppServiceType = exports.CppSearchScanConsistency = exports.CppSearchHighlightStyle = exports.CppQueryScanConsistency = exports.CppQueryProfile = exports.CppDiagPingState = exports.CppDiagEndpointState = exports.CppDiagClusterState = exports.CppDesignDocumentNamespace = exports.CppAnalyticsScanConsistency = exports.CppProtocolSubdocOpcode = exports.CppRetryReason = exports.CppManagementRbacAuthDomain = exports.CppManagementEventingFunctionProcessingStatus = exports.CppManagementEventingFunctionDeploymentStatus = exports.CppManagementEventingFunctionStatus = exports.CppManagementEventingFunctionBucketAccess = exports.CppManagementEventingFunctionLogLevel = exports.CppManagementEventingFunctionLanguageCompatibility = exports.CppManagementEventingFunctionDcpBoundary = exports.CppManagementClusterBucketStorageBackend = exports.CppManagementClusterBucketConflictResolution = exports.CppManagementClusterBucketEvictionPolicy = exports.CppManagementClusterBucketCompression = exports.CppManagementClusterBucketType = exports.CppManagementAnalyticsCouchbaseLinkEncryptionLevel = exports.zeroCas = void 0;
6
+ exports.CppTxnExternalException = exports.CppTxnFailureType = exports.CppVectorQueryCombination = exports.CppReplicateTo = exports.CppPersistTo = exports.CppStoreSemantics = exports.CppImplSubdocOpcode = exports.CppKeyValueStatusCode = exports.CppErrcNetwork = exports.CppErrcFieldLevelEncryption = exports.CppErrcManagement = exports.CppErrcView = exports.CppErrcSearch = exports.CppErrcAnalytics = exports.CppErrcQuery = exports.CppErrcKeyValue = exports.CppErrcCommon = exports.CppDurabilityLevel = exports.CppAnalyticsResponseAnalyticsStatus = exports.CppViewSortOrder = exports.CppViewScanConsistency = exports.CppViewOnError = exports.CppServiceType = exports.CppSearchScanConsistency = exports.CppSearchHighlightStyle = exports.CppQueryScanConsistency = exports.CppQueryProfile = exports.CppDiagPingState = exports.CppDiagEndpointState = exports.CppDiagClusterState = exports.CppDesignDocumentNamespace = exports.CppAnalyticsScanConsistency = exports.CppProtocolSubdocOpcode = exports.CppRetryReason = exports.CppManagementRbacAuthDomain = exports.CppManagementEventingFunctionProcessingStatus = exports.CppManagementEventingFunctionDeploymentStatus = exports.CppManagementEventingFunctionStatus = exports.CppManagementEventingFunctionBucketAccess = exports.CppManagementEventingFunctionLogLevel = exports.CppManagementEventingFunctionLanguageCompatibility = exports.CppManagementEventingFunctionDcpBoundary = exports.CppManagementClusterBucketStorageBackend = exports.CppManagementClusterBucketConflictResolution = exports.CppManagementClusterBucketEvictionPolicy = exports.CppManagementClusterBucketCompression = exports.CppManagementClusterBucketType = exports.CppManagementAnalyticsCouchbaseLinkEncryptionLevel = exports.zeroCas = void 0;
7
7
  /*
8
8
  eslint
9
9
  jsdoc/require-jsdoc: off,
@@ -147,6 +147,9 @@ var CppPersistTo;
147
147
  var CppReplicateTo;
148
148
  (function (CppReplicateTo) {
149
149
  })(CppReplicateTo || (exports.CppReplicateTo = CppReplicateTo = {}));
150
+ var CppVectorQueryCombination;
151
+ (function (CppVectorQueryCombination) {
152
+ })(CppVectorQueryCombination || (exports.CppVectorQueryCombination = CppVectorQueryCombination = {}));
150
153
  var CppTxnFailureType;
151
154
  (function (CppTxnFailureType) {
152
155
  })(CppTxnFailureType || (exports.CppTxnFailureType = CppTxnFailureType = {}));
@@ -1,5 +1,5 @@
1
1
  import { AnalyticsScanConsistency, AnalyticsStatus } from './analyticstypes';
2
- import { CppAnalyticsResponseAnalyticsStatus, CppAnalyticsScanConsistency, CppDiagEndpointState, CppDiagPingState, CppDurabilityLevel, CppError, CppManagementClusterBucketCompression, CppManagementClusterBucketConflictResolution, CppManagementClusterBucketEvictionPolicy, CppManagementClusterBucketStorageBackend, CppManagementClusterBucketType, CppMutationState, CppPersistTo, CppPrefixScan, CppQueryProfile, CppQueryScanConsistency, CppRangeScan, CppReplicateTo, CppSamplingScan, CppSearchHighlightStyle, CppSearchScanConsistency, CppServiceType, CppStoreSemantics, CppTxnExternalException, CppTxnOpException, CppViewScanConsistency, CppViewSortOrder } from './binding';
2
+ import { CppAnalyticsResponseAnalyticsStatus, CppAnalyticsScanConsistency, CppDiagEndpointState, CppDiagPingState, CppDurabilityLevel, CppError, CppManagementClusterBucketCompression, CppManagementClusterBucketConflictResolution, CppManagementClusterBucketEvictionPolicy, CppManagementClusterBucketStorageBackend, CppManagementClusterBucketType, CppMutationState, CppPersistTo, CppPrefixScan, CppQueryProfile, CppQueryScanConsistency, CppRangeScan, CppReplicateTo, CppSamplingScan, CppSearchHighlightStyle, CppSearchScanConsistency, CppServiceType, CppStoreSemantics, CppTxnExternalException, CppTxnOpException, CppVectorQueryCombination, CppViewScanConsistency, CppViewSortOrder } from './binding';
3
3
  import { BucketType, CompressionMode, ConflictResolutionType, EvictionPolicy, StorageBackend } from './bucketmanager';
4
4
  import { EndpointState, PingState } from './diagnosticstypes';
5
5
  import { ErrorContext } from './errorcontexts';
@@ -8,6 +8,7 @@ import { MutationState } from './mutationstate';
8
8
  import { QueryProfileMode, QueryScanConsistency } from './querytypes';
9
9
  import { PrefixScan, RangeScan, SamplingScan } from './rangeScan';
10
10
  import { HighlightStyle, SearchScanConsistency } from './searchtypes';
11
+ import { VectorQueryCombination } from './vectorsearch';
11
12
  import { ViewOrdering, ViewScanConsistency } from './viewtypes';
12
13
  /**
13
14
  * @internal
@@ -141,3 +142,7 @@ export declare function bucketConflictResolutionTypeToCpp(type: ConflictResoluti
141
142
  * @internal
142
143
  */
143
144
  export declare function bucketConflictResolutionTypeFromCpp(type: CppManagementClusterBucketConflictResolution): ConflictResolutionType | undefined;
145
+ /**
146
+ * @internal
147
+ */
148
+ export declare function vectorQueryCombinationToCpp(combination: VectorQueryCombination | undefined): CppVectorQueryCombination;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.bucketConflictResolutionTypeFromCpp = exports.bucketConflictResolutionTypeToCpp = exports.bucketStorageBackendFromCpp = exports.bucketStorageBackendToCpp = exports.bucketEvictionPolicyFromCpp = exports.bucketEvictionPolicyToCpp = exports.bucketCompressionModeFromCpp = exports.bucketCompressionModeToCpp = exports.bucketTypeFromCpp = exports.bucketTypeToCpp = exports.scanTypeToCpp = exports.errorFromCpp = exports.contextFromCpp = exports.pingStateFromCpp = exports.txnOpExeptionFromCpp = exports.txnExternalExceptionStringFromCpp = exports.endpointStateFromCpp = exports.serviceTypeFromCpp = exports.serviceTypeToCpp = exports.mutationStateToCpp = exports.searchHighlightStyleToCpp = exports.searchScanConsistencyToCpp = exports.analyticsStatusFromCpp = exports.analyticsScanConsistencyToCpp = exports.queryProfileToCpp = exports.queryScanConsistencyToCpp = exports.viewOrderingToCpp = exports.viewScanConsistencyToCpp = exports.storeSemanticToCpp = exports.replicateToToCpp = exports.persistToToCpp = exports.durabilityFromCpp = exports.durabilityToCpp = void 0;
29
+ exports.vectorQueryCombinationToCpp = exports.bucketConflictResolutionTypeFromCpp = exports.bucketConflictResolutionTypeToCpp = exports.bucketStorageBackendFromCpp = exports.bucketStorageBackendToCpp = exports.bucketEvictionPolicyFromCpp = exports.bucketEvictionPolicyToCpp = exports.bucketCompressionModeFromCpp = exports.bucketCompressionModeToCpp = exports.bucketTypeFromCpp = exports.bucketTypeToCpp = exports.scanTypeToCpp = exports.errorFromCpp = exports.contextFromCpp = exports.pingStateFromCpp = exports.txnOpExeptionFromCpp = exports.txnExternalExceptionStringFromCpp = exports.endpointStateFromCpp = exports.serviceTypeFromCpp = exports.serviceTypeToCpp = exports.mutationStateToCpp = exports.searchHighlightStyleToCpp = exports.searchScanConsistencyToCpp = exports.analyticsStatusFromCpp = exports.analyticsScanConsistencyToCpp = exports.queryProfileToCpp = exports.queryScanConsistencyToCpp = exports.viewOrderingToCpp = exports.viewScanConsistencyToCpp = exports.storeSemanticToCpp = exports.replicateToToCpp = exports.persistToToCpp = exports.durabilityFromCpp = exports.durabilityToCpp = void 0;
30
30
  const analyticstypes_1 = require("./analyticstypes");
31
31
  const binding_1 = __importDefault(require("./binding"));
32
32
  const bucketmanager_1 = require("./bucketmanager");
@@ -38,6 +38,7 @@ const querytypes_1 = require("./querytypes");
38
38
  const rangeScan_1 = require("./rangeScan");
39
39
  const searchtypes_1 = require("./searchtypes");
40
40
  const utilities_1 = require("./utilities");
41
+ const vectorsearch_1 = require("./vectorsearch");
41
42
  const viewtypes_1 = require("./viewtypes");
42
43
  /**
43
44
  * @internal
@@ -1011,3 +1012,16 @@ function bucketConflictResolutionTypeFromCpp(type) {
1011
1012
  throw new errs.InvalidArgumentError();
1012
1013
  }
1013
1014
  exports.bucketConflictResolutionTypeFromCpp = bucketConflictResolutionTypeFromCpp;
1015
+ /**
1016
+ * @internal
1017
+ */
1018
+ function vectorQueryCombinationToCpp(combination) {
1019
+ if (combination === vectorsearch_1.VectorQueryCombination.AND) {
1020
+ return binding_1.default.vector_query_combination.combination_and;
1021
+ }
1022
+ else if (combination === vectorsearch_1.VectorQueryCombination.OR) {
1023
+ return binding_1.default.vector_query_combination.combination_or;
1024
+ }
1025
+ throw new errs.InvalidArgumentError(new Error('Unrecognized VectorQueryCombination.'));
1026
+ }
1027
+ exports.vectorQueryCombinationToCpp = vectorQueryCombinationToCpp;
package/dist/cluster.d.ts CHANGED
@@ -10,7 +10,7 @@ import { QueryIndexManager } from './queryindexmanager';
10
10
  import { QueryMetaData, QueryOptions, QueryResult } from './querytypes';
11
11
  import { SearchIndexManager } from './searchindexmanager';
12
12
  import { SearchQuery } from './searchquery';
13
- import { SearchMetaData, SearchQueryOptions, SearchResult, SearchRow } from './searchtypes';
13
+ import { SearchMetaData, SearchQueryOptions, SearchRequest, SearchResult, SearchRow } from './searchtypes';
14
14
  import { StreamableRowPromise } from './streamablepromises';
15
15
  import { Transactions, TransactionsConfig } from './transactions';
16
16
  import { Transcoder } from './transcoders';
@@ -300,6 +300,17 @@ export declare class Cluster {
300
300
  * @param callback A node-style callback to be invoked after execution.
301
301
  */
302
302
  searchQuery(indexName: string, query: SearchQuery, options?: SearchQueryOptions, callback?: NodeCallback<SearchResult>): StreamableRowPromise<SearchResult, SearchRow, SearchMetaData>;
303
+ /**
304
+ * Executes a search query against the cluster.
305
+ *
306
+ * Volatile: This API is subject to change at any time.
307
+ *
308
+ * @param indexName The name of the index to query.
309
+ * @param request The SearchRequest describing the search to execute.
310
+ * @param options Optional parameters for this operation.
311
+ * @param callback A node-style callback to be invoked after execution.
312
+ */
313
+ search(indexName: string, request: SearchRequest, options?: SearchQueryOptions, callback?: NodeCallback<SearchResult>): StreamableRowPromise<SearchResult, SearchRow, SearchMetaData>;
303
314
  /**
304
315
  * Returns a diagnostics report about the currently active connections with the
305
316
  * cluster. Includes information about remote and local addresses, last activity,
package/dist/cluster.js CHANGED
@@ -317,6 +317,28 @@ class Cluster {
317
317
  const options_ = options;
318
318
  return utilities_1.PromiseHelper.wrapAsync(() => exec.query(indexName, query, options_), callback);
319
319
  }
320
+ /**
321
+ * Executes a search query against the cluster.
322
+ *
323
+ * Volatile: This API is subject to change at any time.
324
+ *
325
+ * @param indexName The name of the index to query.
326
+ * @param request The SearchRequest describing the search to execute.
327
+ * @param options Optional parameters for this operation.
328
+ * @param callback A node-style callback to be invoked after execution.
329
+ */
330
+ search(indexName, request, options, callback) {
331
+ if (options instanceof Function) {
332
+ callback = arguments[2];
333
+ options = undefined;
334
+ }
335
+ if (!options) {
336
+ options = {};
337
+ }
338
+ const exec = new searchexecutor_1.SearchExecutor(this);
339
+ const options_ = options;
340
+ return utilities_1.PromiseHelper.wrapAsync(() => exec.query(indexName, request, options_), callback);
341
+ }
320
342
  /**
321
343
  * Returns a diagnostics report about the currently active connections with the
322
344
  * cluster. Includes information about remote and local addresses, last activity,
@@ -70,6 +70,7 @@ export * from './streamablepromises';
70
70
  export * from './transactions';
71
71
  export * from './transcoders';
72
72
  export * from './usermanager';
73
+ export * from './vectorsearch';
73
74
  export * from './viewexecutor';
74
75
  export * from './viewindexmanager';
75
76
  export * from './viewtypes';
package/dist/couchbase.js CHANGED
@@ -99,6 +99,7 @@ __exportStar(require("./streamablepromises"), exports);
99
99
  __exportStar(require("./transactions"), exports);
100
100
  __exportStar(require("./transcoders"), exports);
101
101
  __exportStar(require("./usermanager"), exports);
102
+ __exportStar(require("./vectorsearch"), exports);
102
103
  __exportStar(require("./viewexecutor"), exports);
103
104
  __exportStar(require("./viewindexmanager"), exports);
104
105
  __exportStar(require("./viewtypes"), exports);
@@ -1,6 +1,6 @@
1
1
  import { Cluster } from './cluster';
2
2
  import { SearchQuery } from './searchquery';
3
- import { SearchMetaData, SearchQueryOptions, SearchResult, SearchRow } from './searchtypes';
3
+ import { SearchMetaData, SearchQueryOptions, SearchRequest, SearchResult, SearchRow } from './searchtypes';
4
4
  import { StreamableRowPromise } from './streamablepromises';
5
5
  /**
6
6
  * @internal
@@ -14,5 +14,5 @@ export declare class SearchExecutor {
14
14
  /**
15
15
  * @internal
16
16
  */
17
- query(indexName: string, query: SearchQuery, options: SearchQueryOptions): StreamableRowPromise<SearchResult, SearchRow, SearchMetaData>;
17
+ query(indexName: string, query: SearchQuery | SearchRequest, options: SearchQueryOptions): StreamableRowPromise<SearchResult, SearchRow, SearchMetaData>;
18
18
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SearchExecutor = void 0;
4
4
  /* eslint jsdoc/require-jsdoc: off */
5
5
  const bindingutilities_1 = require("./bindingutilities");
6
+ const searchquery_1 = require("./searchquery");
6
7
  const searchtypes_1 = require("./searchtypes");
7
8
  const streamablepromises_1 = require("./streamablepromises");
8
9
  /**
@@ -25,11 +26,16 @@ class SearchExecutor {
25
26
  meta: meta,
26
27
  });
27
28
  });
29
+ const searchQuery = query instanceof searchquery_1.SearchQuery
30
+ ? JSON.stringify(query)
31
+ : query.searchQuery
32
+ ? JSON.stringify(query.searchQuery)
33
+ : JSON.stringify(new searchquery_1.MatchNoneSearchQuery());
28
34
  const timeout = options.timeout || this._cluster.searchTimeout;
29
- this._cluster.conn.search({
35
+ const request = {
30
36
  timeout,
31
37
  index_name: indexName,
32
- query: JSON.stringify(query),
38
+ query: searchQuery,
33
39
  limit: options.limit,
34
40
  skip: options.skip,
35
41
  explain: options.explain || false,
@@ -59,7 +65,17 @@ class SearchExecutor {
59
65
  .map(([k, v]) => [k, JSON.stringify(v)]))
60
66
  : {},
61
67
  body_str: '',
62
- }, (cppErr, resp) => {
68
+ };
69
+ if (query instanceof searchtypes_1.SearchRequest) {
70
+ request.show_request = false;
71
+ if (query.vectorSearch) {
72
+ request.vector_search = JSON.stringify(query.vectorSearch.queries);
73
+ if (query.vectorSearch.options && query.vectorSearch.options.vectorQueryCombination) {
74
+ request.vector_query_combination = (0, bindingutilities_1.vectorQueryCombinationToCpp)(query.vectorSearch.options.vectorQueryCombination);
75
+ }
76
+ }
77
+ }
78
+ this._cluster.conn.search(request, (cppErr, resp) => {
63
79
  const err = (0, bindingutilities_1.errorFromCpp)(cppErr);
64
80
  if (err) {
65
81
  emitter.emit('error', err);
@@ -1,6 +1,8 @@
1
1
  import { MutationState } from './mutationstate';
2
2
  import { SearchFacet } from './searchfacet';
3
+ import { SearchQuery } from './searchquery';
3
4
  import { SearchSort } from './searchsort';
5
+ import { VectorSearch } from './vectorsearch';
4
6
  /**
5
7
  * SearchMetaData represents the meta-data available from a search query.
6
8
  * This class is currently incomplete and must be casted to `any` in
@@ -145,3 +147,47 @@ export interface SearchQueryOptions {
145
147
  */
146
148
  timeout?: number;
147
149
  }
150
+ /**
151
+ * Represents a search query and/or vector search to execute via the Couchbase Full Text Search (FTS) service.
152
+ *
153
+ * Volatile: This API is subject to change at any time.
154
+ *
155
+ * @category Full Text Search
156
+ */
157
+ export declare class SearchRequest {
158
+ private _searchQuery;
159
+ private _vectorSearch;
160
+ constructor(query: SearchQuery | VectorSearch);
161
+ /**
162
+ * @internal
163
+ */
164
+ get searchQuery(): SearchQuery | undefined;
165
+ /**
166
+ * @internal
167
+ */
168
+ get vectorSearch(): VectorSearch | undefined;
169
+ /**
170
+ * Adds a search query to the request if the request does not already have a search query.
171
+ *
172
+ * Volatile: This API is subject to change at any time.
173
+ *
174
+ * @param query A SearchQuery to add to the request.
175
+ */
176
+ withSearchQuery(query: SearchQuery): SearchRequest;
177
+ /**
178
+ * Adds a vector search to the request if the request does not already have a vector search.
179
+ *
180
+ * Volatile: This API is subject to change at any time.
181
+ *
182
+ * @param search A VectorSearch to add to the request.
183
+ */
184
+ withVectorSearch(search: VectorSearch): SearchRequest;
185
+ /**
186
+ * Creates a search request.
187
+ *
188
+ * Volatile: This API is subject to change at any time.
189
+ *
190
+ * @param query Either a SearchQuery or VectorSearch to add to the search request.
191
+ */
192
+ static create(query: SearchQuery | VectorSearch): SearchRequest;
193
+ }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SearchScanConsistency = exports.HighlightStyle = exports.SearchResult = exports.SearchRow = exports.SearchMetaData = void 0;
3
+ exports.SearchRequest = exports.SearchScanConsistency = exports.HighlightStyle = exports.SearchResult = exports.SearchRow = exports.SearchMetaData = void 0;
4
+ const errors_1 = require("./errors");
5
+ const searchquery_1 = require("./searchquery");
6
+ const vectorsearch_1 = require("./vectorsearch");
4
7
  /**
5
8
  * SearchMetaData represents the meta-data available from a search query.
6
9
  * This class is currently incomplete and must be casted to `any` in
@@ -67,3 +70,80 @@ var SearchScanConsistency;
67
70
  */
68
71
  SearchScanConsistency["NotBounded"] = "not_bounded";
69
72
  })(SearchScanConsistency || (exports.SearchScanConsistency = SearchScanConsistency = {}));
73
+ /**
74
+ * Represents a search query and/or vector search to execute via the Couchbase Full Text Search (FTS) service.
75
+ *
76
+ * Volatile: This API is subject to change at any time.
77
+ *
78
+ * @category Full Text Search
79
+ */
80
+ class SearchRequest {
81
+ constructor(query) {
82
+ if (query instanceof searchquery_1.SearchQuery) {
83
+ this._searchQuery = query;
84
+ }
85
+ else if (query instanceof vectorsearch_1.VectorSearch) {
86
+ this._vectorSearch = query;
87
+ }
88
+ else {
89
+ throw new errors_1.InvalidArgumentError(new Error('Must provide either a SearchQuery or VectorSearch when creating SearchRequest.'));
90
+ }
91
+ }
92
+ /**
93
+ * @internal
94
+ */
95
+ get searchQuery() {
96
+ return this._searchQuery;
97
+ }
98
+ /**
99
+ * @internal
100
+ */
101
+ get vectorSearch() {
102
+ return this._vectorSearch;
103
+ }
104
+ /**
105
+ * Adds a search query to the request if the request does not already have a search query.
106
+ *
107
+ * Volatile: This API is subject to change at any time.
108
+ *
109
+ * @param query A SearchQuery to add to the request.
110
+ */
111
+ withSearchQuery(query) {
112
+ if (!(query instanceof searchquery_1.SearchQuery)) {
113
+ throw new errors_1.InvalidArgumentError(new Error('Must provide a SearchQuery.'));
114
+ }
115
+ if (this._searchQuery) {
116
+ throw new errors_1.InvalidArgumentError(new Error('Request already has a SearchQuery.'));
117
+ }
118
+ this._searchQuery = query;
119
+ return this;
120
+ }
121
+ /**
122
+ * Adds a vector search to the request if the request does not already have a vector search.
123
+ *
124
+ * Volatile: This API is subject to change at any time.
125
+ *
126
+ * @param search A VectorSearch to add to the request.
127
+ */
128
+ withVectorSearch(search) {
129
+ if (!(search instanceof vectorsearch_1.VectorSearch)) {
130
+ throw new errors_1.InvalidArgumentError(new Error('Must provide a VectorSearch.'));
131
+ }
132
+ if (this._vectorSearch) {
133
+ throw new errors_1.InvalidArgumentError(new Error('Request already has a VectorSearch.'));
134
+ }
135
+ this._vectorSearch = search;
136
+ return this;
137
+ }
138
+ /**
139
+ * Creates a search request.
140
+ *
141
+ * Volatile: This API is subject to change at any time.
142
+ *
143
+ * @param query Either a SearchQuery or VectorSearch to add to the search request.
144
+ */
145
+ static create(query) {
146
+ return new SearchRequest(query);
147
+ }
148
+ }
149
+ exports.SearchRequest = SearchRequest;