Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
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#include <memory>
35
36#ifndef COUCHBASE_CXX_CLIENT_DOXYGEN
37namespace couchbase
38{
39namespace core
40{
41class cluster;
42} // namespace core
43class search_index_manager_impl;
44} // namespace couchbase
45#endif
46
47namespace couchbase
48{
49class cluster;
50
52{
53public:
64 void get_index(std::string index_name,
65 const get_search_index_options& options,
66 get_search_index_handler&& handler) const;
67
68 [[nodiscard]] auto get_index(std::string index_name, const get_search_index_options& options = {})
69 const -> std::future<std::pair<error, management::search::index>>;
70
81 get_all_search_indexes_handler&& handler) const;
82
83 [[nodiscard]] auto get_all_indexes(const get_all_search_indexes_options& options = {}) const
84 -> std::future<std::pair<error, std::vector<management::search::index>>>;
85
96 void upsert_index(const management::search::index& search_index,
97 const upsert_search_index_options& options,
98 upsert_search_index_handler&& handler) const;
99
100 [[nodiscard]] auto upsert_index(const management::search::index& search_index,
101 const upsert_search_index_options& options = {}) const
102 -> std::future<error>;
103
114 void drop_index(std::string index_name,
115 const drop_search_index_options& options,
116 drop_search_index_handler&& handler) const;
117
118 [[nodiscard]] auto drop_index(std::string index_name,
119 const drop_search_index_options& options = {}) const
120 -> std::future<error>;
121
132 void get_indexed_documents_count(std::string index_name,
134 get_indexed_search_index_handler&& handler) const;
135
136 [[nodiscard]] auto get_indexed_documents_count(
137 std::string index_name,
138 const get_indexed_search_index_options& options = {}) const
139 -> std::future<std::pair<error, std::uint64_t>>;
140
151 void pause_ingest(std::string index_name,
153 pause_ingest_search_index_handler&& handler) const;
154
155 [[nodiscard]] auto pause_ingest(std::string index_name,
156 const pause_ingest_search_index_options& options = {}) const
157 -> std::future<error>;
158
169 void resume_ingest(std::string index_name,
171 resume_ingest_search_index_handler&& handler) const;
172
173 [[nodiscard]] auto resume_ingest(std::string index_name,
174 const resume_ingest_search_index_options& options = {}) const
175 -> std::future<error>;
176
187 void allow_querying(std::string index_name,
190
191 [[nodiscard]] auto allow_querying(std::string index_name,
192 const allow_querying_search_index_options& options = {}) const
193 -> std::future<error>;
194
205 void disallow_querying(std::string index_name,
208
209 [[nodiscard]] auto disallow_querying(
210 std::string index_name,
211 const disallow_querying_search_index_options& options = {}) const -> std::future<error>;
212
223 void freeze_plan(std::string index_name,
225 freeze_plan_search_index_handler&& handler) const;
226
227 [[nodiscard]] auto freeze_plan(std::string index_name,
228 const freeze_plan_search_index_options& options = {}) const
229 -> std::future<error>;
230
241 void unfreeze_plan(std::string index_name,
243 unfreeze_plan_search_index_handler&& handler) const;
244
245 [[nodiscard]] auto unfreeze_plan(std::string index_name,
246 const unfreeze_plan_search_index_options& options = {}) const
247 -> std::future<error>;
248
260 template<typename Document>
261 void analyze_document(std::string index_name,
262 Document document,
263 const analyze_document_options& options,
264 analyze_document_handler&& handler) const
265 {
267 document); // Encode as JSON and convert to string
268 auto decoded =
269 std::string{ reinterpret_cast<const char*>(encoded.data.data()), encoded.data.size() };
270 return analyze_document(std::move(index_name), decoded, options, std::move(handler));
271 }
272
273 template<typename Document>
274 [[nodiscard]] auto analyze_document(std::string index_name,
275 Document document,
276 const analyze_document_options& options = {}) const
277 -> std::future<std::pair<error, std::vector<std::string>>>
278 {
280 document); // Encode as JSON and convert to string
281 auto decoded =
282 std::string{ reinterpret_cast<const char*>(encoded.data.data()), encoded.data.size() };
283
284 return analyze_document(std::move(index_name), decoded, options);
285 }
286
298 void analyze_document(std::string index_name,
299 std::string document,
300 const analyze_document_options& options,
301 analyze_document_handler&& handler) const;
302
303 [[nodiscard]] auto analyze_document(std::string index_name,
304 std::string document,
305 const analyze_document_options& options) const
306 -> std::future<std::pair<error, std::vector<std::string>>>;
307
308private:
309 friend class cluster;
310
311 explicit search_index_manager(core::cluster core);
312
313 std::shared_ptr<search_index_manager_impl> impl_;
314};
315} // namespace couchbase
The cluster is the main entry point when connecting to a Couchbase cluster.
Definition cluster.hxx:60
static auto encode(Document document) -> encoded_value
Definition json_transcoder.hxx:33
Definition error.hxx:30
Definition search_index_manager.hxx:52
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 an 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 an 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 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 an 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 an 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 an 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 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 search_index_manager.hxx:274
void drop_index(std::string index_name, const drop_search_index_options &options, drop_search_index_handler &&handler) const
Drops an 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 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 index.
Definition search_index_manager.hxx:261
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 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 an 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 an index.
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