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

The input text is analyzed and a phrase query is built with the terms resulting from the analysis. More...

#include <couchbase/match_phrase_query.hxx>

Inheritance diagram for match_phrase_query:
Inheritance graph

Public Member Functions

 match_phrase_query (std::string match_phrase)
 Create a new match phrase query.
 
auto analyzer (std::string analyzer_name) -> match_phrase_query &
 Analyzers are used to transform input text into a stream of tokens for indexing.
 
auto field (std::string field_name) -> match_phrase_query &
 If a field is specified, only terms in that field will be matched.
 
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

The input text is analyzed and a phrase query is built with the terms resulting from the analysis.

This type of query searches for terms occurring in the specified positions and offsets. This depends on term vectors, which are consulted to determine phrase distance.

For example, a match phrase query for "location for functions" is matched with "locate the function", if the standard analyzer is used: this analyzer uses a stemmer, which tokenizes "location" and "locate" to "locat", and reduces "functions" and "function" to "function". Additionally, the analyzer employs stop removal, which removes small and less significant words from input and target text, so that matches are attempted on only the more significant elements of vocabulary: in this case "for" and "the" are removed. Following this processing, the tokens "locat" and "function" are recognized as common to both input and target; and also as being both in the same sequence as, and at the same distance from one another; and therefore a match is made.

auto query = couchbase::match_phrase_query("nice view").field("reviews.content");
See also
https://docs.couchbase.com/server/current/fts/fts-supported-queries-match-phrase.html
Since
1.0.0
Committed
Generally available API and should be preferred in production

Constructor & Destructor Documentation

◆ match_phrase_query()

match_phrase_query ( std::string match_phrase)
inlineexplicit

Create a new match phrase query.

Parameters
match_phrasethe 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_phrase_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_phrase_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

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