Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
scope_search_index_manager.hxx
Go to the documentation of this file.
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
32
33#include <future>
34
35#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
36namespace couchbase
37{
38namespace core
39{
40class cluster;
41} // namespace core
42class search_index_manager_impl;
43} // namespace couchbase
44#endif
45
46namespace couchbase
47{
48class scope;
49
51{
52public:
63 void get_index(std::string index_name,
64 const get_search_index_options& options,
65 get_search_index_handler&& handler) const;
66
67 [[nodiscard]] auto get_index(std::string index_name, const get_search_index_options& options = {})
68 const -> std::future<std::pair<error, management::search::index>>;
69
80 get_all_search_indexes_handler&& handler) const;
81
82 [[nodiscard]] auto get_all_indexes(const get_all_search_indexes_options& options = {}) const
83 -> std::future<std::pair<error, std::vector<management::search::index>>>;
84
95 void upsert_index(const management::search::index& search_index,
96 const upsert_search_index_options& options,
97 upsert_search_index_handler&& handler) const;
98
99 [[nodiscard]] auto upsert_index(const management::search::index& search_index,
100 const upsert_search_index_options& options = {}) const
101 -> std::future<error>;
102
113 void drop_index(std::string index_name,
114 const drop_search_index_options& options,
115 drop_search_index_handler&& handler) const;
116
117 [[nodiscard]] auto drop_index(std::string index_name,
118 const drop_search_index_options& options = {}) const
119 -> std::future<error>;
120
131 void get_indexed_documents_count(std::string index_name,
133 get_indexed_search_index_handler&& handler) const;
134
135 [[nodiscard]] auto get_indexed_documents_count(
136 std::string index_name,
137 const get_indexed_search_index_options& options = {}) const
138 -> std::future<std::pair<error, std::uint64_t>>;
139
150 void pause_ingest(std::string index_name,
152 pause_ingest_search_index_handler&& handler) const;
153
154 [[nodiscard]] auto pause_ingest(std::string index_name,
155 const pause_ingest_search_index_options& options = {}) const
156 -> std::future<error>;
157
168 void resume_ingest(std::string index_name,
170 resume_ingest_search_index_handler&& handler) const;
171
172 [[nodiscard]] auto resume_ingest(std::string index_name,
173 const resume_ingest_search_index_options& options = {}) const
174 -> std::future<error>;
175
186 void allow_querying(std::string index_name,
189
190 [[nodiscard]] auto allow_querying(std::string index_name,
191 const allow_querying_search_index_options& options = {}) const
192 -> std::future<error>;
193
204 void disallow_querying(std::string index_name,
207
208 [[nodiscard]] auto disallow_querying(
209 std::string index_name,
210 const disallow_querying_search_index_options& options = {}) const -> std::future<error>;
211
222 void freeze_plan(std::string index_name,
224 freeze_plan_search_index_handler&& handler) const;
225
226 [[nodiscard]] auto freeze_plan(std::string index_name,
227 const freeze_plan_search_index_options& options = {}) const
228 -> std::future<error>;
229
240 void unfreeze_plan(std::string index_name,
242 unfreeze_plan_search_index_handler&& handler) const;
243
244 [[nodiscard]] auto unfreeze_plan(std::string index_name,
245 const unfreeze_plan_search_index_options& options = {}) const
246 -> std::future<error>;
247
259 template<typename Document>
260 void analyze_document(std::string index_name,
261 Document document,
262 const analyze_document_options& options,
263 analyze_document_handler&& handler) const
264 {
266 document); // Encode as JSON and convert to string
267 auto decoded =
268 std::string{ reinterpret_cast<const char*>(encoded.data.data()), encoded.data.size() };
269 return analyze_document(std::move(index_name), decoded, options, std::move(handler));
270 }
271
272 template<typename Document>
273 [[nodiscard]] auto analyze_document(std::string index_name,
274 Document document,
275 const analyze_document_options& options = {}) const
276 -> std::future<std::pair<error, std::vector<std::string>>>
277 {
279 document); // Encode as JSON and convert to string
280 auto decoded =
281 std::string{ reinterpret_cast<const char*>(encoded.data.data()), encoded.data.size() };
282
283 return analyze_document(std::move(index_name), decoded, options);
284 }
285
297 void analyze_document(std::string index_name,
298 std::string document,
299 const analyze_document_options& options,
300 analyze_document_handler&& handler) const;
301
302 [[nodiscard]] auto analyze_document(std::string index_name,
303 std::string document,
304 const analyze_document_options& options) const
305 -> std::future<std::pair<error, std::vector<std::string>>>;
306
307private:
308 friend class scope;
309
310 explicit scope_search_index_manager(core::cluster core,
311 std::string bucket_name,
312 std::string scope_name);
313
314 std::shared_ptr<search_index_manager_impl> impl_;
315};
316} // namespace couchbase
static auto encode(Document document) -> encoded_value
Definition json_transcoder.hxx:33
Definition error.hxx:30
Definition scope_search_index_manager.hxx:51
auto analyze_document(std::string index_name, std::string document, const analyze_document_options &options) const -> std::future< std::pair< error, std::vector< std::string > > >
auto resume_ingest(std::string index_name, const resume_ingest_search_index_options &options={}) const -> std::future< error >
auto get_index(std::string index_name, const get_search_index_options &options={}) const -> std::future< std::pair< error, management::search::index > >
auto disallow_querying(std::string index_name, const disallow_querying_search_index_options &options={}) const -> std::future< error >
void allow_querying(std::string index_name, const allow_querying_search_index_options &options, allow_querying_search_index_handler &&handler) const
Allows querying against a scope-level index.
auto pause_ingest(std::string index_name, const pause_ingest_search_index_options &options={}) const -> std::future< error >
auto get_all_indexes(const get_all_search_indexes_options &options={}) const -> std::future< std::pair< error, std::vector< management::search::index > > >
void get_indexed_documents_count(std::string index_name, const get_indexed_search_index_options &options, get_indexed_search_index_handler &&handler) const
Retrieves the number of documents that have been indexed for a scope-level index.
auto get_indexed_documents_count(std::string index_name, const get_indexed_search_index_options &options={}) const -> std::future< std::pair< error, std::uint64_t > >
void get_all_indexes(const get_all_search_indexes_options &options, get_all_search_indexes_handler &&handler) const
Fetches all scope-level indexes from the server.
auto upsert_index(const management::search::index &search_index, const upsert_search_index_options &options={}) const -> std::future< error >
void get_index(std::string index_name, const get_search_index_options &options, get_search_index_handler &&handler) const
Fetches a scope-level index from the server if it exists.
void upsert_index(const management::search::index &search_index, const upsert_search_index_options &options, upsert_search_index_handler &&handler) const
Creates, or updates a scope-level index.
auto allow_querying(std::string index_name, const allow_querying_search_index_options &options={}) const -> std::future< error >
void disallow_querying(std::string index_name, const disallow_querying_search_index_options &options, disallow_querying_search_index_handler &&handler) const
Disallows querying against a scope-level index.
auto drop_index(std::string index_name, const drop_search_index_options &options={}) const -> std::future< error >
void analyze_document(std::string index_name, std::string document, const analyze_document_options &options, analyze_document_handler &&handler) const
Allows to see how a document is analyzed against a specific scope-level index.
auto analyze_document(std::string index_name, Document document, const analyze_document_options &options={}) const -> std::future< std::pair< error, std::vector< std::string > > >
Definition scope_search_index_manager.hxx:273
void drop_index(std::string index_name, const drop_search_index_options &options, drop_search_index_handler &&handler) const
Drops a scope-level index.
void freeze_plan(std::string index_name, const freeze_plan_search_index_options &options, freeze_plan_search_index_handler &&handler) const
Freeze the assignment of scope-level index partitions to nodes.
void analyze_document(std::string index_name, Document document, const analyze_document_options &options, analyze_document_handler &&handler) const
Allows to see how a document is analyzed against a specific scope-level index.
Definition scope_search_index_manager.hxx:260
auto freeze_plan(std::string index_name, const freeze_plan_search_index_options &options={}) const -> std::future< error >
auto unfreeze_plan(std::string index_name, const unfreeze_plan_search_index_options &options={}) const -> std::future< error >
void unfreeze_plan(std::string index_name, const unfreeze_plan_search_index_options &options, unfreeze_plan_search_index_handler &&handler) const
Unfreeze the assignment of scope-level index partitions to nodes.
void pause_ingest(std::string index_name, const pause_ingest_search_index_options &options, pause_ingest_search_index_handler &&handler) const
Pauses updates and maintenance for a scope-level index.
void resume_ingest(std::string index_name, const resume_ingest_search_index_options &options, resume_ingest_search_index_handler &&handler) const
Resumes updates and maintenance for a scope-level index.
The scope identifies a group of collections and allows high application density as a result.
Definition scope.hxx:47
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
std::function< void(error, management::search::index)> get_search_index_handler
Definition get_search_index_options.hxx:43
std::function< void(error, std::uint64_t)> get_indexed_search_index_handler
Definition get_indexed_search_index_options.hxx:42
std::function< void(error)> unfreeze_plan_search_index_handler
Definition unfreeze_plan_search_index_options.hxx:43
std::function< void(error)> allow_querying_search_index_handler
Definition allow_querying_search_index_options.hxx:43
std::function< void(error)> drop_search_index_handler
Definition drop_search_index_options.hxx:42
std::function< void(error, std::vector< std::string >)> analyze_document_handler
Definition analyze_document_options.hxx:43
std::function< void(error)> freeze_plan_search_index_handler
Definition freeze_plan_search_index_options.hxx:42
std::function< void(error)> resume_ingest_search_index_handler
Definition resume_ingest_search_index_options.hxx:43
std::function< void(error, std::vector< management::search::index >)> get_all_search_indexes_handler
Definition get_all_search_indexes_options.hxx:43
std::function< void(error)> upsert_search_index_handler
Definition upsert_search_index_options.hxx:40
std::function< void(error)> disallow_querying_search_index_handler
Definition disallow_querying_search_index_options.hxx:43
std::function< void(error)> pause_ingest_search_index_handler
Definition pause_ingest_search_index_options.hxx:43
Definition allow_querying_search_index_options.hxx:30
Definition analyze_document_options.hxx:30
Definition disallow_querying_search_index_options.hxx:30
Definition drop_search_index_options.hxx:29
Definition freeze_plan_search_index_options.hxx:29
Definition get_all_search_indexes_options.hxx:30
Definition get_indexed_search_index_options.hxx:29
Definition get_search_index_options.hxx:30
Definition search_index.hxx:27
Definition pause_ingest_search_index_options.hxx:30
Definition resume_ingest_search_index_options.hxx:30
Definition unfreeze_plan_search_index_options.hxx:30
Definition upsert_search_index_options.hxx:27