couchbase 3.0.0.alpha.2 → 3.0.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests-dev-preview.yml +52 -0
- data/.gitmodules +3 -0
- data/.idea/vcs.xml +1 -0
- data/.yardopts +1 -0
- data/README.md +1 -1
- data/Rakefile +5 -1
- data/bin/init-cluster +13 -5
- data/couchbase.gemspec +2 -1
- data/examples/managing_query_indexes.rb +1 -1
- data/examples/managing_search_indexes.rb +62 -0
- data/examples/search.rb +187 -0
- data/ext/.clang-tidy +1 -0
- data/ext/build_version.hxx.in +1 -1
- data/ext/couchbase/bucket.hxx +0 -40
- data/ext/couchbase/couchbase.cxx +2578 -1368
- data/ext/couchbase/io/http_session.hxx +27 -7
- data/ext/couchbase/io/mcbp_parser.hxx +2 -0
- data/ext/couchbase/io/mcbp_session.hxx +53 -24
- data/ext/couchbase/io/session_manager.hxx +6 -1
- data/ext/couchbase/operations.hxx +13 -0
- data/ext/couchbase/operations/bucket_create.hxx +1 -0
- data/ext/couchbase/operations/bucket_drop.hxx +1 -0
- data/ext/couchbase/operations/bucket_flush.hxx +1 -0
- data/ext/couchbase/operations/bucket_get.hxx +1 -0
- data/ext/couchbase/operations/bucket_get_all.hxx +1 -0
- data/ext/couchbase/operations/bucket_update.hxx +1 -0
- data/ext/couchbase/operations/cluster_developer_preview_enable.hxx +1 -0
- data/ext/couchbase/operations/collection_create.hxx +6 -1
- data/ext/couchbase/operations/collection_drop.hxx +1 -0
- data/ext/couchbase/operations/command.hxx +86 -11
- data/ext/couchbase/operations/document_decrement.hxx +1 -0
- data/ext/couchbase/operations/document_exists.hxx +1 -0
- data/ext/couchbase/operations/document_get.hxx +1 -0
- data/ext/couchbase/operations/document_get_and_lock.hxx +1 -0
- data/ext/couchbase/operations/document_get_and_touch.hxx +1 -0
- data/ext/couchbase/operations/document_get_projected.hxx +243 -0
- data/ext/couchbase/operations/document_increment.hxx +4 -1
- data/ext/couchbase/operations/document_insert.hxx +1 -0
- data/ext/couchbase/operations/document_lookup_in.hxx +1 -0
- data/ext/couchbase/operations/document_mutate_in.hxx +1 -0
- data/ext/couchbase/operations/document_query.hxx +13 -2
- data/ext/couchbase/operations/document_remove.hxx +1 -0
- data/ext/couchbase/operations/document_replace.hxx +1 -0
- data/ext/couchbase/operations/document_search.hxx +337 -0
- data/ext/couchbase/operations/document_touch.hxx +1 -0
- data/ext/couchbase/operations/document_unlock.hxx +1 -0
- data/ext/couchbase/operations/document_upsert.hxx +1 -0
- data/ext/couchbase/operations/query_index_build_deferred.hxx +1 -0
- data/ext/couchbase/operations/query_index_create.hxx +1 -0
- data/ext/couchbase/operations/query_index_drop.hxx +1 -0
- data/ext/couchbase/operations/query_index_get_all.hxx +1 -0
- data/ext/couchbase/operations/scope_create.hxx +1 -0
- data/ext/couchbase/operations/scope_drop.hxx +1 -0
- data/ext/couchbase/operations/scope_get_all.hxx +2 -0
- data/ext/couchbase/operations/search_index.hxx +62 -0
- data/ext/couchbase/operations/search_index_analyze_document.hxx +92 -0
- data/ext/couchbase/operations/search_index_control_ingest.hxx +78 -0
- data/ext/couchbase/operations/search_index_control_plan_freeze.hxx +80 -0
- data/ext/couchbase/operations/search_index_control_query.hxx +80 -0
- data/ext/couchbase/operations/search_index_drop.hxx +77 -0
- data/ext/couchbase/operations/search_index_get.hxx +80 -0
- data/ext/couchbase/operations/search_index_get_all.hxx +82 -0
- data/ext/couchbase/operations/search_index_get_documents_count.hxx +81 -0
- data/ext/couchbase/operations/search_index_upsert.hxx +106 -0
- data/ext/couchbase/protocol/client_opcode.hxx +10 -0
- data/ext/couchbase/protocol/cmd_get_collection_id.hxx +117 -0
- data/ext/couchbase/timeout_defaults.hxx +32 -0
- data/ext/couchbase/version.hxx +1 -1
- data/ext/test/main.cxx +5 -5
- data/lib/couchbase/binary_collection.rb +16 -12
- data/lib/couchbase/binary_collection_options.rb +4 -0
- data/lib/couchbase/cluster.rb +88 -8
- data/lib/couchbase/collection.rb +39 -15
- data/lib/couchbase/collection_options.rb +19 -2
- data/lib/couchbase/json_transcoder.rb +2 -2
- data/lib/couchbase/management/bucket_manager.rb +37 -23
- data/lib/couchbase/management/collection_manager.rb +15 -6
- data/lib/couchbase/management/query_index_manager.rb +16 -6
- data/lib/couchbase/management/search_index_manager.rb +61 -14
- data/lib/couchbase/search_options.rb +1492 -0
- data/lib/couchbase/version.rb +1 -1
- metadata +22 -2
@@ -0,0 +1,77 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020 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 <tao/json.hpp>
|
21
|
+
|
22
|
+
#include <version.hxx>
|
23
|
+
|
24
|
+
namespace couchbase::operations
|
25
|
+
{
|
26
|
+
struct search_index_drop_response {
|
27
|
+
uuid::uuid_t client_context_id;
|
28
|
+
std::error_code ec;
|
29
|
+
std::string status{};
|
30
|
+
std::string error{};
|
31
|
+
};
|
32
|
+
|
33
|
+
struct search_index_drop_request {
|
34
|
+
using response_type = search_index_drop_response;
|
35
|
+
using encoded_request_type = io::http_request;
|
36
|
+
using encoded_response_type = io::http_response;
|
37
|
+
|
38
|
+
static const inline service_type type = service_type::search;
|
39
|
+
|
40
|
+
uuid::uuid_t client_context_id{ uuid::random() };
|
41
|
+
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
42
|
+
|
43
|
+
std::string index_name;
|
44
|
+
|
45
|
+
void encode_to(encoded_request_type& encoded)
|
46
|
+
{
|
47
|
+
encoded.method = "DELETE";
|
48
|
+
encoded.path = fmt::format("/api/index/{}", index_name);
|
49
|
+
}
|
50
|
+
};
|
51
|
+
|
52
|
+
search_index_drop_response
|
53
|
+
make_response(std::error_code ec, search_index_drop_request& request, search_index_drop_request::encoded_response_type encoded)
|
54
|
+
{
|
55
|
+
search_index_drop_response response{ request.client_context_id, ec };
|
56
|
+
if (!ec) {
|
57
|
+
if (encoded.status_code == 200) {
|
58
|
+
auto payload = tao::json::from_string(encoded.body);
|
59
|
+
response.status = payload.at("status").get_string();
|
60
|
+
if (response.status == "ok") {
|
61
|
+
return response;
|
62
|
+
}
|
63
|
+
} else if (encoded.status_code == 400) {
|
64
|
+
auto payload = tao::json::from_string(encoded.body);
|
65
|
+
response.status = payload.at("status").get_string();
|
66
|
+
response.error = payload.at("error").get_string();
|
67
|
+
if (response.error.find("index not found") != std::string::npos) {
|
68
|
+
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
69
|
+
return response;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
73
|
+
}
|
74
|
+
return response;
|
75
|
+
}
|
76
|
+
|
77
|
+
} // namespace couchbase::operations
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020 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 <tao/json.hpp>
|
21
|
+
#include <operations/search_index.hxx>
|
22
|
+
|
23
|
+
#include <version.hxx>
|
24
|
+
|
25
|
+
namespace couchbase::operations
|
26
|
+
{
|
27
|
+
struct search_index_get_response {
|
28
|
+
uuid::uuid_t client_context_id;
|
29
|
+
std::error_code ec;
|
30
|
+
std::string status{};
|
31
|
+
search_index index{};
|
32
|
+
std::string error{};
|
33
|
+
};
|
34
|
+
|
35
|
+
struct search_index_get_request {
|
36
|
+
using response_type = search_index_get_response;
|
37
|
+
using encoded_request_type = io::http_request;
|
38
|
+
using encoded_response_type = io::http_response;
|
39
|
+
|
40
|
+
static const inline service_type type = service_type::search;
|
41
|
+
|
42
|
+
uuid::uuid_t client_context_id{ uuid::random() };
|
43
|
+
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
44
|
+
|
45
|
+
std::string index_name;
|
46
|
+
|
47
|
+
void encode_to(encoded_request_type& encoded)
|
48
|
+
{
|
49
|
+
encoded.method = "GET";
|
50
|
+
encoded.path = fmt::format("/api/index/{}", index_name);
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
search_index_get_response
|
55
|
+
make_response(std::error_code ec, search_index_get_request& request, search_index_get_request::encoded_response_type encoded)
|
56
|
+
{
|
57
|
+
search_index_get_response response{ request.client_context_id, ec };
|
58
|
+
if (!ec) {
|
59
|
+
if (encoded.status_code == 200) {
|
60
|
+
auto payload = tao::json::from_string(encoded.body);
|
61
|
+
response.status = payload.at("status").get_string();
|
62
|
+
if (response.status == "ok") {
|
63
|
+
response.index = payload.at("indexDef").as<search_index>();
|
64
|
+
return response;
|
65
|
+
}
|
66
|
+
} else if (encoded.status_code == 400) {
|
67
|
+
auto payload = tao::json::from_string(encoded.body);
|
68
|
+
response.status = payload.at("status").get_string();
|
69
|
+
response.error = payload.at("error").get_string();
|
70
|
+
if (response.error.find("index not found") != std::string::npos) {
|
71
|
+
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
72
|
+
return response;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
76
|
+
}
|
77
|
+
return response;
|
78
|
+
}
|
79
|
+
|
80
|
+
} // namespace couchbase::operations
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020 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 <tao/json.hpp>
|
21
|
+
#include <operations/search_index.hxx>
|
22
|
+
|
23
|
+
#include <version.hxx>
|
24
|
+
|
25
|
+
namespace couchbase::operations
|
26
|
+
{
|
27
|
+
struct search_index_get_all_response {
|
28
|
+
uuid::uuid_t client_context_id;
|
29
|
+
std::error_code ec;
|
30
|
+
std::string status{};
|
31
|
+
std::string impl_version{};
|
32
|
+
std::vector<search_index> indexes{};
|
33
|
+
};
|
34
|
+
|
35
|
+
struct search_index_get_all_request {
|
36
|
+
using response_type = search_index_get_all_response;
|
37
|
+
using encoded_request_type = io::http_request;
|
38
|
+
using encoded_response_type = io::http_response;
|
39
|
+
|
40
|
+
static const inline service_type type = service_type::search;
|
41
|
+
|
42
|
+
uuid::uuid_t client_context_id{ uuid::random() };
|
43
|
+
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
44
|
+
|
45
|
+
std::string index_name;
|
46
|
+
|
47
|
+
void encode_to(encoded_request_type& encoded)
|
48
|
+
{
|
49
|
+
encoded.method = "GET";
|
50
|
+
encoded.path = fmt::format("/api/index");
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
search_index_get_all_response
|
55
|
+
make_response(std::error_code ec, search_index_get_all_request& request, search_index_get_all_request::encoded_response_type encoded)
|
56
|
+
{
|
57
|
+
search_index_get_all_response response{ request.client_context_id, ec };
|
58
|
+
if (!ec) {
|
59
|
+
if (encoded.status_code == 200) {
|
60
|
+
auto payload = tao::json::from_string(encoded.body);
|
61
|
+
response.status = payload.at("status").get_string();
|
62
|
+
if (response.status == "ok") {
|
63
|
+
const auto* indexDefs = payload.find("indexDefs");
|
64
|
+
if (indexDefs != nullptr && indexDefs->is_object()) {
|
65
|
+
const auto* impl_ver = indexDefs->find("implVersion");
|
66
|
+
if (impl_ver != nullptr && impl_ver->is_string()) {
|
67
|
+
response.impl_version = impl_ver->get_string();
|
68
|
+
}
|
69
|
+
const auto* indexes = indexDefs->find("indexDefs");
|
70
|
+
for (const auto& entry : indexes->get_object()) {
|
71
|
+
response.indexes.emplace_back(entry.second.as<search_index>());
|
72
|
+
}
|
73
|
+
}
|
74
|
+
return response;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
return response;
|
78
|
+
}
|
79
|
+
return response;
|
80
|
+
}
|
81
|
+
|
82
|
+
} // namespace couchbase::operations
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020 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 <tao/json.hpp>
|
21
|
+
|
22
|
+
#include <version.hxx>
|
23
|
+
|
24
|
+
namespace couchbase::operations
|
25
|
+
{
|
26
|
+
struct search_index_get_documents_count_response {
|
27
|
+
uuid::uuid_t client_context_id;
|
28
|
+
std::error_code ec;
|
29
|
+
std::string status{};
|
30
|
+
std::uint64_t count{ 0 };
|
31
|
+
std::string error{};
|
32
|
+
};
|
33
|
+
|
34
|
+
struct search_index_get_documents_count_request {
|
35
|
+
using response_type = search_index_get_documents_count_response;
|
36
|
+
using encoded_request_type = io::http_request;
|
37
|
+
using encoded_response_type = io::http_response;
|
38
|
+
|
39
|
+
static const inline service_type type = service_type::search;
|
40
|
+
|
41
|
+
uuid::uuid_t client_context_id{ uuid::random() };
|
42
|
+
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
43
|
+
|
44
|
+
std::string index_name;
|
45
|
+
|
46
|
+
void encode_to(encoded_request_type& encoded)
|
47
|
+
{
|
48
|
+
encoded.method = "GET";
|
49
|
+
encoded.path = fmt::format("/api/index/{}/count", index_name);
|
50
|
+
}
|
51
|
+
};
|
52
|
+
|
53
|
+
search_index_get_documents_count_response
|
54
|
+
make_response(std::error_code ec,
|
55
|
+
search_index_get_documents_count_request& request,
|
56
|
+
search_index_get_documents_count_request::encoded_response_type encoded)
|
57
|
+
{
|
58
|
+
search_index_get_documents_count_response response{ request.client_context_id, ec };
|
59
|
+
if (!ec) {
|
60
|
+
if (encoded.status_code == 200) {
|
61
|
+
auto payload = tao::json::from_string(encoded.body);
|
62
|
+
response.status = payload.at("status").get_string();
|
63
|
+
if (response.status == "ok") {
|
64
|
+
response.count = payload.at("count").get_unsigned();
|
65
|
+
return response;
|
66
|
+
}
|
67
|
+
} else if (encoded.status_code == 400) {
|
68
|
+
auto payload = tao::json::from_string(encoded.body);
|
69
|
+
response.status = payload.at("status").get_string();
|
70
|
+
response.error = payload.at("error").get_string();
|
71
|
+
if (response.error.find("index not found") != std::string::npos) {
|
72
|
+
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
73
|
+
return response;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
77
|
+
}
|
78
|
+
return response;
|
79
|
+
}
|
80
|
+
|
81
|
+
} // namespace couchbase::operations
|
@@ -0,0 +1,106 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2020 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 <tao/json.hpp>
|
21
|
+
|
22
|
+
#include <version.hxx>
|
23
|
+
|
24
|
+
namespace couchbase::operations
|
25
|
+
{
|
26
|
+
struct search_index_upsert_response {
|
27
|
+
uuid::uuid_t client_context_id;
|
28
|
+
std::error_code ec;
|
29
|
+
std::string status{};
|
30
|
+
std::string error{};
|
31
|
+
};
|
32
|
+
|
33
|
+
struct search_index_upsert_request {
|
34
|
+
using response_type = search_index_upsert_response;
|
35
|
+
using encoded_request_type = io::http_request;
|
36
|
+
using encoded_response_type = io::http_response;
|
37
|
+
|
38
|
+
static const inline service_type type = service_type::search;
|
39
|
+
|
40
|
+
uuid::uuid_t client_context_id{ uuid::random() };
|
41
|
+
std::chrono::milliseconds timeout{ timeout_defaults::management_timeout };
|
42
|
+
|
43
|
+
search_index index;
|
44
|
+
|
45
|
+
void encode_to(encoded_request_type& encoded)
|
46
|
+
{
|
47
|
+
encoded.method = "PUT";
|
48
|
+
encoded.headers["cache-control"] = "no-cache";
|
49
|
+
encoded.headers["content-type"] = "application/json";
|
50
|
+
encoded.path = fmt::format("/api/index/{}", index.name);
|
51
|
+
tao::json::value body{
|
52
|
+
{ "name", index.name },
|
53
|
+
{ "type", index.type },
|
54
|
+
{ "sourceType", index.source_type },
|
55
|
+
};
|
56
|
+
if (!index.uuid.empty()) {
|
57
|
+
body["uuid"] = index.uuid;
|
58
|
+
}
|
59
|
+
if (!index.params_json.empty()) {
|
60
|
+
body["params"] = tao::json::from_string(index.params_json);
|
61
|
+
}
|
62
|
+
if (!index.source_name.empty()) {
|
63
|
+
body["sourceName"] = index.source_name;
|
64
|
+
}
|
65
|
+
if (!index.source_uuid.empty()) {
|
66
|
+
body["sourceUUID"] = index.source_uuid;
|
67
|
+
}
|
68
|
+
if (!index.source_params_json.empty()) {
|
69
|
+
body["sourceParams"] = tao::json::from_string(index.source_params_json);
|
70
|
+
}
|
71
|
+
if (!index.plan_params_json.empty()) {
|
72
|
+
body["planParams"] = tao::json::from_string(index.plan_params_json);
|
73
|
+
}
|
74
|
+
encoded.body = tao::json::to_string(body);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
search_index_upsert_response
|
79
|
+
make_response(std::error_code ec, search_index_upsert_request& request, search_index_upsert_request::encoded_response_type encoded)
|
80
|
+
{
|
81
|
+
search_index_upsert_response response{ request.client_context_id, ec };
|
82
|
+
if (!ec) {
|
83
|
+
if (encoded.status_code == 200) {
|
84
|
+
auto payload = tao::json::from_string(encoded.body);
|
85
|
+
response.status = payload.at("status").get_string();
|
86
|
+
if (response.status == "ok") {
|
87
|
+
return response;
|
88
|
+
}
|
89
|
+
} else if (encoded.status_code == 400) {
|
90
|
+
auto payload = tao::json::from_string(encoded.body);
|
91
|
+
response.status = payload.at("status").get_string();
|
92
|
+
response.error = payload.at("error").get_string();
|
93
|
+
if (response.error.find("index not found") != std::string::npos) {
|
94
|
+
response.ec = std::make_error_code(error::common_errc::index_not_found);
|
95
|
+
return response;
|
96
|
+
} else if (response.error.find("index with the same name already exists") != std::string::npos) {
|
97
|
+
response.ec = std::make_error_code(error::common_errc::index_exists);
|
98
|
+
return response;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
response.ec = std::make_error_code(error::common_errc::internal_server_failure);
|
102
|
+
}
|
103
|
+
return response;
|
104
|
+
}
|
105
|
+
|
106
|
+
} // namespace couchbase::operations
|
@@ -41,6 +41,7 @@ enum class client_opcode : uint8_t {
|
|
41
41
|
get_and_lock = 0x94,
|
42
42
|
unlock = 0x95,
|
43
43
|
get_collections_manifest = 0xba,
|
44
|
+
get_collection_id = 0xbb,
|
44
45
|
subdoc_multi_lookup = 0xd0,
|
45
46
|
subdoc_multi_mutation = 0xd1,
|
46
47
|
get_cluster_config = 0xb5,
|
@@ -52,6 +53,7 @@ enum class client_opcode : uint8_t {
|
|
52
53
|
* subdocument opcodes are listed separately, because we are not going to implement/support single-op messages
|
53
54
|
*/
|
54
55
|
enum class subdoc_opcode : uint8_t {
|
56
|
+
get_doc = 0x00,
|
55
57
|
get = 0xc5,
|
56
58
|
exists = 0xc6,
|
57
59
|
dict_add = 0xc7,
|
@@ -93,6 +95,7 @@ is_valid_client_opcode(uint8_t code)
|
|
93
95
|
case client_opcode::get_and_touch:
|
94
96
|
case client_opcode::increment:
|
95
97
|
case client_opcode::decrement:
|
98
|
+
case client_opcode::get_collection_id:
|
96
99
|
return true;
|
97
100
|
}
|
98
101
|
return false;
|
@@ -114,6 +117,7 @@ is_valid_subdoc_opcode(uint8_t code)
|
|
114
117
|
case subdoc_opcode::array_add_unique:
|
115
118
|
case subdoc_opcode::counter:
|
116
119
|
case subdoc_opcode::get_count:
|
120
|
+
case subdoc_opcode::get_doc:
|
117
121
|
return true;
|
118
122
|
}
|
119
123
|
return false;
|
@@ -196,6 +200,9 @@ struct fmt::formatter |
|
196
200
|
case couchbase::protocol::client_opcode::decrement:
|
197
201
|
name = "decrement";
|
198
202
|
break;
|
203
|
+
case couchbase::protocol::client_opcode::get_collection_id:
|
204
|
+
name = "get_collection_uid";
|
205
|
+
break;
|
199
206
|
}
|
200
207
|
return formatter<string_view>::format(name, ctx);
|
201
208
|
}
|
@@ -244,6 +251,9 @@ struct fmt::formatter |
|
244
251
|
case couchbase::protocol::subdoc_opcode::get_count:
|
245
252
|
name = "get_count";
|
246
253
|
break;
|
254
|
+
case couchbase::protocol::subdoc_opcode::get_doc:
|
255
|
+
name = "get_doc";
|
256
|
+
break;
|
247
257
|
}
|
248
258
|
return formatter<string_view>::format(name, ctx);
|
249
259
|
}
|