MongoDB C++ Driver mongocxx-3.10.1
Loading...
Searching...
No Matches
index.hpp
1// Copyright 2015 MongoDB Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <chrono>
18#include <memory>
19
20#include <mongocxx/collection-fwd.hpp>
21#include <mongocxx/options/index-fwd.hpp>
22
23#include <bsoncxx/document/value.hpp>
24#include <bsoncxx/document/view.hpp>
25#include <bsoncxx/document/view_or_value.hpp>
26#include <bsoncxx/stdx/optional.hpp>
27#include <bsoncxx/string/view_or_value.hpp>
28#include <mongocxx/stdx.hpp>
29
30#include <mongocxx/config/prelude.hpp>
31
32namespace mongocxx {
33namespace v_noabi {
34namespace options {
35
41class index {
42 public:
46 class MONGOCXX_API base_storage_options {
47 public:
48 virtual ~base_storage_options();
49
50 private:
51 friend ::mongocxx::v_noabi::options::index;
52
53 MONGOCXX_PRIVATE virtual int type() const = 0;
54 };
55
59 class MONGOCXX_API wiredtiger_storage_options final : public base_storage_options {
60 public:
62
70
76 const stdx::optional<bsoncxx::v_noabi::string::view_or_value>& config_string() const;
77
78 private:
79 friend ::mongocxx::v_noabi::collection;
80
81 MONGOCXX_PRIVATE int type() const override;
82
83 stdx::optional<bsoncxx::v_noabi::string::view_or_value> _config_string;
84 };
85
86 index();
87
102
108 const stdx::optional<bool>& background() const;
109
124
130 const stdx::optional<bool>& unique() const;
131
146
152 const stdx::optional<bool>& hidden() const;
153
165
171 const stdx::optional<bsoncxx::v_noabi::string::view_or_value>& name() const;
172
187
197 const stdx::optional<bsoncxx::v_noabi::document::view>& collation() const;
198
213
219 const stdx::optional<bool>& sparse() const;
220
232 index& storage_options(std::unique_ptr<base_storage_options> storage_options);
233
241 index& storage_options(std::unique_ptr<wiredtiger_storage_options> storage_options);
242
256 index& expire_after(std::chrono::seconds seconds);
257
263 const stdx::optional<std::chrono::seconds>& expire_after() const;
264
275 index& version(std::int32_t v);
276
282 const stdx::optional<std::int32_t>& version() const;
283
296
302 const stdx::optional<bsoncxx::v_noabi::document::view>& weights() const;
303
316
322 const stdx::optional<bsoncxx::v_noabi::string::view_or_value>& default_language() const;
323
336
342 const stdx::optional<bsoncxx::v_noabi::string::view_or_value>& language_override() const;
343
355
361 const stdx::optional<bsoncxx::v_noabi::document::view>& partial_filter_expression() const;
362
374
380 const stdx::optional<std::uint8_t>& twod_sphere_version() const;
381
393
399 const stdx::optional<std::uint8_t>& twod_bits_precision() const;
400
412
418 const stdx::optional<double>& twod_location_min() const;
419
431
437 const stdx::optional<double>& twod_location_max() const;
438
456 MONGOCXX_DEPRECATED index& haystack_bucket_size(double haystack_bucket_size);
457 index& haystack_bucket_size_deprecated(double haystack_bucket_size);
458
467 MONGOCXX_DEPRECATED const stdx::optional<double>& haystack_bucket_size() const;
468 const stdx::optional<double>& haystack_bucket_size_deprecated() const;
469
479
480 private:
481 friend ::mongocxx::v_noabi::collection;
482
483 stdx::optional<bool> _background;
484 stdx::optional<bool> _unique;
485 stdx::optional<bool> _hidden;
486 stdx::optional<bsoncxx::v_noabi::string::view_or_value> _name;
487 stdx::optional<bsoncxx::v_noabi::document::view> _collation;
488 stdx::optional<bool> _sparse;
489 std::unique_ptr<base_storage_options> _storage_options;
490 stdx::optional<std::chrono::seconds> _expire_after;
491 stdx::optional<std::int32_t> _version;
492 stdx::optional<bsoncxx::v_noabi::document::view> _weights;
493 stdx::optional<bsoncxx::v_noabi::string::view_or_value> _default_language;
494 stdx::optional<bsoncxx::v_noabi::string::view_or_value> _language_override;
495 stdx::optional<bsoncxx::v_noabi::document::view> _partial_filter_expression;
496 stdx::optional<std::uint8_t> _twod_sphere_version;
497 stdx::optional<std::uint8_t> _twod_bits_precision;
498 stdx::optional<double> _twod_location_min;
499 stdx::optional<double> _twod_location_max;
500 stdx::optional<double> _haystack_bucket_size;
501
502 //
503 // Return the current storage_options setting.
504 //
505 const std::unique_ptr<base_storage_options>& storage_options() const;
506};
507
508} // namespace options
509} // namespace v_noabi
510} // namespace mongocxx
511
512#include <mongocxx/config/postlude.hpp>
A read-only, non-owning view of a BSON document.
Definition view.hpp:35
Class representing a view-or-value variant type for strings.
Definition view_or_value.hpp:38
Base class representing the optional storage engine options for indexes.
Definition index.hpp:46
Class representing the optional WiredTiger storage engine options for indexes.
Definition index.hpp:59
void config_string(bsoncxx::v_noabi::string::view_or_value config_string)
Set the WiredTiger configuration string.
const stdx::optional< bsoncxx::v_noabi::string::view_or_value > & config_string() const
The current config_string setting.
Class representing the optional arguments to a MongoDB create index operation.
Definition index.hpp:41
index & haystack_bucket_size(double haystack_bucket_size)
For geoHaystack indexes, specify the number of units within which to group the location values; i....
index & hidden(bool hidden)
Whether or not the index is hidden from the query planner.
index & language_override(bsoncxx::v_noabi::string::view_or_value language_override)
For text indexes, the name of the field, in the collection’s documents, that contains the override la...
const stdx::optional< double > & haystack_bucket_size() const
The current haystack_bucket_size setting.
index & twod_location_max(double twod_location_max)
For 2d indexes, the upper inclusive boundary for the longitude and latitude values.
const stdx::optional< bsoncxx::v_noabi::string::view_or_value > & language_override() const
The current name of the field that contains the override language for text indexes.
const stdx::optional< bool > & unique() const
The current unique setting.
index & background(bool background)
Whether or not to build the index in the background so that building the index does not block other d...
index & expire_after(std::chrono::seconds seconds)
Set a value, in seconds, as a TTL to control how long MongoDB retains documents in this collection.
index & weights(bsoncxx::v_noabi::document::view weights)
For text indexes, sets the weight document.
const stdx::optional< double > & twod_location_max() const
The current upper inclusive boundary for the longitude and latitude values.
index & unique(bool unique)
Whether or not to create a unique index so that the collection will not accept insertion of documents...
const stdx::optional< std::int32_t > & version() const
The current index version.
const stdx::optional< bsoncxx::v_noabi::document::view > & collation() const
Retrieves the current collation for this index.
index & storage_options(std::unique_ptr< base_storage_options > storage_options)
Optionally used only in MongoDB 3.0.0 and higher.
const stdx::optional< bsoncxx::v_noabi::string::view_or_value > & name() const
The current name setting.
const stdx::optional< bsoncxx::v_noabi::string::view_or_value > & default_language() const
The current default_language setting.
index & collation(bsoncxx::v_noabi::document::view collation)
Sets the collation for this index.
index & name(bsoncxx::v_noabi::string::view_or_value name)
The name of the index.
const stdx::optional< bool > & hidden() const
The current hidden setting.
const stdx::optional< std::uint8_t > & twod_sphere_version() const
The current twod_sphere_version setting.
const stdx::optional< std::uint8_t > & twod_bits_precision() const
The current precision of the stored geohash value of the location data.
const stdx::optional< double > & twod_location_min() const
The current lower inclusive boundary for the longitude and latitude values.
const stdx::optional< bool > & sparse() const
The current sparse setting.
const stdx::optional< bool > & background() const
The current background setting.
index & version(std::int32_t v)
Sets the index version.
index & twod_location_min(double twod_location_min)
For 2d indexes, the lower inclusive boundary for the longitude and latitude values.
index & default_language(bsoncxx::v_noabi::string::view_or_value default_language)
For text indexes, the language that determines the list of stop words and the rules for the stemmer a...
index & twod_bits_precision(std::uint8_t twod_bits_precision)
For 2d indexes, the precision of the stored geohash value of the location data.
const stdx::optional< std::chrono::seconds > & expire_after() const
The current expire_after setting.
index & storage_options(std::unique_ptr< wiredtiger_storage_options > storage_options)
Optionally used only in MongoDB 3.0.0 and higher.
const stdx::optional< bsoncxx::v_noabi::document::view > & partial_filter_expression() const
The current partial_filter_expression setting.
index & partial_filter_expression(bsoncxx::v_noabi::document::view partial_filter_expression)
Sets the document for the partial filter expression for partial indexes.
const stdx::optional< bsoncxx::v_noabi::document::view > & weights() const
The current weights setting.
index & twod_sphere_version(std::uint8_t twod_sphere_version)
For 2dsphere indexes, the 2dsphere index version number.
index & sparse(bool sparse)
Whether or not to create a sparse index.
The top-level namespace for mongocxx library entities.
Definition bulk_write-fwd.hpp:19