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

A query that looks for exact match of several terms (in the exact order) in the index. More...

#include <couchbase/phrase_query.hxx>

Inheritance diagram for phrase_query:
Inheritance graph

Public Member Functions

 phrase_query (std::initializer_list< std::string > terms)
 Create a new phrase query.
 
 phrase_query (std::vector< std::string > terms)
 Create a new phrase query.
 
auto field (std::string field_name) -> 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

A query that looks for exact match of several terms (in the exact order) in the index.

The provided terms must exist in the correct order, at the correct index offsets, in the specified field (as no analyzer are applied to the terms). Queried field must have been indexed with includeTermVectors set to true. It is generally more useful in debugging scenarios, and the match_phrase_query should usually be preferred for real-world use cases.

Match documents with terms "nice" and "view" in field reviews.content:

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

Constructor & Destructor Documentation

◆ phrase_query() [1/2]

phrase_query ( std::initializer_list< std::string > terms)
inlineexplicit

Create a new phrase query.

The mandatory list of terms that must exactly match in 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.

Parameters
termsnon-empty vector of terms.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ phrase_query() [2/2]

phrase_query ( std::vector< std::string > terms)
inlineexplicit

Create a new phrase query.

The mandatory list of terms that must exactly match in 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.

Parameters
termsnon-empty vector of terms.
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) -> phrase_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

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