Couchbase C++ SDK
1.4.0 (rev. 59aa900)
Toggle main menu visibility
Loading...
Searching...
No Matches
term_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
20
#include <
couchbase/match_operator.hxx
>
21
#include <
couchbase/search_query.hxx
>
22
23
#include <cstdint>
24
#include <optional>
25
#include <stdexcept>
26
#include <string>
27
28
namespace
couchbase
29
{
42
class
term_query
:
public
search_query
43
{
44
public
:
59
explicit
term_query
(std::string term)
60
: term_{ std::move(term) }
61
{
62
}
63
80
auto
prefix_length
(std::uint32_t length) ->
term_query
&
81
{
82
if
(length == 0) {
83
throw
std::invalid_argument(
"prefix_length must be positive"
);
84
}
85
86
prefix_length_ = length;
87
return
*
this
;
88
}
89
100
auto
field
(std::string field_name) ->
term_query
&
101
{
102
field_ = std::move(field_name);
103
return
*
this
;
104
}
105
117
auto
fuzziness
(std::uint32_t
fuzziness
) ->
term_query
&
118
{
119
fuzziness_ =
fuzziness
;
120
return
*
this
;
121
}
122
133
auto
match_operator
(
couchbase::match_operator
concatenation_operator) ->
term_query
&
134
{
135
operator_ = concatenation_operator;
136
return
*
this
;
137
}
138
145
[[nodiscard]]
auto
encode
() const -> encoded_search_query override;
146
147
private:
148
std::
string
term_;
149
std::optional<std::uint32_t> prefix_length_{};
150
std::optional<std::string> field_{};
151
std::optional<std::uint32_t> fuzziness_{};
152
std::optional<couchbase::match_operator> operator_{};
153
};
154
}
// namespace couchbase
couchbase::search_query::search_query
search_query()=default
couchbase::term_query::term_query
term_query(std::string term)
Create a new term query.
Definition
term_query.hxx:59
couchbase::term_query::field
auto field(std::string field_name) -> term_query &
If a field is specified, only terms in that field will be matched.
Definition
term_query.hxx:100
couchbase::term_query::match_operator
auto match_operator(couchbase::match_operator concatenation_operator) -> term_query &
Defines how the individual match terms should be logically concatenated.
Definition
term_query.hxx:133
couchbase::term_query::encode
auto encode() const -> encoded_search_query override
couchbase::term_query::prefix_length
auto prefix_length(std::uint32_t length) -> term_query &
Require that the term also have the same prefix of the specified length (must be positive).
Definition
term_query.hxx:80
couchbase::term_query::fuzziness
auto fuzziness(std::uint32_t fuzziness) -> term_query &
Perform fuzzy matching.
Definition
term_query.hxx:117
match_operator.hxx
couchbase
Represents a single item from the result of scan().
Definition
allow_querying_search_index_options.hxx:28
couchbase::match_operator
match_operator
Defines how the individual match terms should be logically concatenated.
Definition
match_operator.hxx:28
search_query.hxx
couchbase
term_query.hxx
Generated by
1.17.0