Couchbase C++ SDK 1.0.1 (rev. 58d46d7)
Loading...
Searching...
No Matches
disjunction_query.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 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
21
22#include <cstdint>
23#include <memory>
24#include <vector>
25
26namespace couchbase
27{
47{
48public:
58 template<typename... SearchQuery>
59 explicit disjunction_query(SearchQuery&&... queries)
60 {
61 or_else(std::forward<SearchQuery>(queries)...);
62 }
63
75 template<typename... SearchQuery>
76 auto or_else(SearchQuery... queries) -> disjunction_query&
77 {
78 (disjuncts_.emplace_back(std::make_shared<SearchQuery>(std::move(queries))), ...);
79 return *this;
80 }
81
92 auto min(std::uint32_t number_of_queries) -> disjunction_query&
93 {
94 min_ = number_of_queries;
95 return *this;
96 }
97
104 [[nodiscard]] auto encode() const -> encoded_search_query override;
105
106private:
107 std::vector<std::shared_ptr<search_query>> disjuncts_{};
108 std::uint32_t min_{ 1 };
109};
110} // namespace couchbase
The disjunction query is a compound query.
Definition disjunction_query.hxx:47
auto min(std::uint32_t number_of_queries) -> disjunction_query &
Set the minimum number of child queries that must be satisfied for the disjunction query.
Definition disjunction_query.hxx:92
disjunction_query(SearchQuery &&... queries)
Create a disjunction query.
Definition disjunction_query.hxx:59
auto encode() const -> encoded_search_query override
auto or_else(SearchQuery... queries) -> disjunction_query &
Add one or more queries to add to the disjunction.
Definition disjunction_query.hxx:76
Base class for full text search queries.
Definition search_query.hxx:33
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28