Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
Loading...
Searching...
No Matches
term_query Class Reference

A query that looks for exact matches of the term in the index (no analyzer, no stemming). More...

#include <couchbase/term_query.hxx>

Inheritance diagram for term_query:
Inheritance graph

Public Member Functions

 term_query (std::string term)
 Create a new term query.
 
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).
 
auto field (std::string field_name) -> term_query &
 If a field is specified, only terms in that field will be matched.
 
auto fuzziness (std::uint32_t fuzziness) -> term_query &
 Perform fuzzy matching.
 
auto match_operator (couchbase::match_operator concatenation_operator) -> term_query &
 Defines how the individual match terms should be logically concatenated.
 
auto encode () const -> encoded_search_query override
 
- Public Member Functions inherited from search_query
virtual ~search_query ()=default
 
template<typename derived_query = search_query, std::enable_if_t< std::is_base_of_v< search_query, derived_query >, bool > = true>
auto boost (double boost) -> derived_query &
 The boost parameter is used to increase the relative weight of a clause (with a boost greater than 1) or decrease the relative weight (with a boost between 0 and 1).
 

Additional Inherited Members

- Protected Member Functions inherited from search_query
 search_query ()=default
 
- Protected Attributes inherited from search_query
std::optional< double > boost_ {}
 

Detailed Description

A query that looks for exact matches of the term in the index (no analyzer, no stemming).

Useful to check what the actual content of the index is. It can also apply fuzziness on the term. Usual better alternative is match_query.

See also
https://docs.couchbase.com/server/current/fts/fts-supported-queries-term.html server documentation
https://docs.couchbase.com/server/current/fts/fts-supported-queries-fuzzy.html fuzzy search
Since
1.0.0
Committed
Generally available API and should be preferred in production

Constructor & Destructor Documentation

◆ term_query()

term_query ( std::string term)
inlineexplicit

Create a new term query.

The mandatory term is the exact string that will be searched into the index. Note that the index can (and usually will) contain terms that are derived from the text in documents, as analyzers can apply process like stemming. For example, indexing "programming" could store "program" in the index. As a term query doesn't apply the analyzers, one would need to look for "program" to have a match on that index entry.

Parameters
termthe input string to be matched against
Since
1.0.0
Committed
Generally available API and should be preferred in production

Member Function Documentation

◆ encode()

auto encode ( ) const -> encoded_search_query
nodiscardoverridevirtual
Returns
encoded representation of the query.
Since
1.0.0
Internal
Internal interface

Implements search_query.

◆ field()

auto field ( std::string field_name) -> term_query&
inline

If a field is specified, only terms in that field will be matched.

Parameters
field_namename of the field to be matched
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ fuzziness()

auto fuzziness ( std::uint32_t fuzziness) -> term_query&
inline

Perform fuzzy matching.

If the fuzziness parameter is set to a non-zero integer the analyzed text will be matched with the specified level of fuzziness.

Parameters
fuzzinesslevel of fuzziness (the maximum supported fuzziness is 2).
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ match_operator()

auto match_operator ( couchbase::match_operator concatenation_operator) -> term_query&
inline

Defines how the individual match terms should be logically concatenated.

Parameters
concatenation_operatoroperator to be used
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ prefix_length()

auto prefix_length ( std::uint32_t length) -> term_query&
inline

Require that the term also have the same prefix of the specified length (must be positive).

The prefix length only makes sense when fuzziness is enabled. It allows to apply the fuzziness only on the part of the term that is after the length character mark.

For example, with the term "something" and a prefix length of 4, only the "thing" part of the term will be fuzzy-searched, and hits must start with "some".

Parameters
lengththe length of the term prefix
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

The documentation for this class was generated from the following file: