Couchbase C++ SDK 1.0.2 (rev. 51f4775)
Loading...
Searching...
No Matches
match_query Class Reference

A match query analyzes the input text and uses that analyzed text to query the index. More...

#include <couchbase/match_query.hxx>

Inheritance diagram for match_query:
Inheritance graph

Public Member Functions

 match_query (std::string match)
 Create a new match query.
 
auto prefix_length (std::uint32_t length) -> match_query &
 Require that the term also have the same prefix of the specified length (must be positive).
 
auto analyzer (std::string analyzer_name) -> match_query &
 Analyzers are used to transform input text into a stream of tokens for indexing.
 
auto field (std::string field_name) -> match_query &
 If a field is specified, only terms in that field will be matched.
 
auto fuzziness (std::uint32_t fuzziness) -> match_query &
 Perform fuzzy matching.
 
auto match_operator (couchbase::match_operator concatenation_operator) -> match_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 match query analyzes the input text and uses that analyzed text to query the index.

An attempt is made to use the same analyzer that was used when the field was indexed.

Match documents with both "location" and "hostel" terms in the field reviews.content, ensuring common prefix length 4, maximum fuzziness and select standard analyzer.

auto query = couchbase::match_query("location hostel")
.field("reviews.content")
.analyzer("standard")
.fuzziness(2)
.prefix_length(4)
See also
https://docs.couchbase.com/server/current/fts/fts-supported-queries-match.html server documentation
Since
1.0.0
Committed
Generally available API and should be preferred in production

Constructor & Destructor Documentation

◆ match_query()

match_query ( std::string match)
inlineexplicit

Create a new match query.

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

Member Function Documentation

◆ analyzer()

auto analyzer ( std::string analyzer_name) -> match_query&
inline

Analyzers are used to transform input text into a stream of tokens for indexing.

The Server comes with built-in analyzers and the users can create their own.

Parameters
analyzer_namethe name of the analyzer used
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ 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) -> match_query&
inline

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

This can also affect the used analyzer if one isn't specified explicitly.

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) -> match_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) -> match_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) -> match_query&
inline

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

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: