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

The query string query allows humans to describe complex queries using a simple syntax. More...

#include <couchbase/query_string_query.hxx>

Inheritance diagram for query_string_query:
Inheritance graph

Public Member Functions

 query_string_query (std::string query)
 Create a new query string query.
 
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 query string query allows humans to describe complex queries using a simple syntax.

  1. When you specify multiple query-clauses, you can specify the relative importance to a given clause by suffixing it with the ^ operator, followed by a number or by specifying the boost parameter with the number to boost the search. For example perform match_query for pool in both the name and description fields, but documents having the term in the name field score higher.
    couchbase::query_string_query query(R"(description:pool name:pool^5)");
  2. You can perform date or numeric range searches by using the >, >=, <, and <= operators, followed by a date value in quotes. For example, perform a date_range_query on the created field for values after September 21, 2016.
    couchbase::query_string_query query(R"(created:>"2016-09-21")");
    Or, perform a numeric_range_query on the reviews.ratings.Cleanliness field, for values greater than 4.
    couchbase::query_string_query query(R"(reviews.ratings.Cleanliness:>4)");
See also
https://docs.couchbase.com/server/current/fts/fts-query-string-syntax.html definition of query syntax
Since
1.0.0
Committed
Generally available API and should be preferred in production

Constructor & Destructor Documentation

◆ query_string_query()

query_string_query ( std::string query)
inlineexplicit

Create a new query string query.

Parameters
querythe query string to be analyzed and used 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.


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