Couchbase C++ SDK 1.0.1 (rev. 58d46d7)
Loading...
Searching...
No Matches
date_range_query Class Reference

The date range query finds documents containing a date value in the specified field within the specified range. More...

#include <couchbase/date_range_query.hxx>

Inheritance diagram for date_range_query:
Inheritance graph

Public Member Functions

auto start (std::chrono::system_clock::time_point value) -> date_range_query &
 Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.
 
auto start (std::tm value) -> date_range_query &
 Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.
 
auto start (std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query &
 Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.
 
auto start (std::tm value, bool inclusive) -> date_range_query &
 Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.
 
auto start (std::string value) -> date_range_query &
 Set preformatted date as lower limit.
 
auto start (std::string value, bool inclusive) -> date_range_query &
 Set preformatted date as lower limit.
 
auto end (std::chrono::system_clock::time_point value) -> date_range_query &
 Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.
 
auto end (std::tm value) -> date_range_query &
 Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.
 
auto end (std::chrono::system_clock::time_point value, bool inclusive) -> date_range_query &
 Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.
 
auto end (std::tm value, bool inclusive) -> date_range_query &
 Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.
 
auto end (std::string value)
 Set preformatted date as upper limit.
 
auto end (std::string value, bool inclusive) -> date_range_query &
 Set preformatted date as upper limit.
 
auto date_time_parser (std::string parser_name) -> date_range_query &
 Enable custom date parser.
 
auto field (std::string field_name) -> date_range_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 date range query finds documents containing a date value in the specified field within the specified range.

Either start or end can be omitted, but not both.

Match documents where field review_date falls within the range ("2001-10-09T10:20:30-08:00", "2016-10-31")

.field("review_date")
.start("2001-10-09T10:20:30-08:00", /* inclusive= */ false)
.end("2016-10-31", /* inclusive= */ false);

It also works with std::tm and std::chrono::system_clock::time_point.

std::tm start_tm{};
start_tm.tm_year = 2001 - 1900;
start_tm.tm_mon = 9;
start_tm.tm_mday = 9;
start_tm.tm_hour = 10;
start_tm.tm_min = 20;
start_tm.tm_sec = 30;
std::tm end_tm{};
end_tm.tm_year = 2001 - 1900;
end_tm.tm_mon = 9;
end_tm.tm_mday = 31;
.field("review_date")
.start(start_tm)
.end(end_tm);
// equivalent of {"field":"review_date","start":"2001-10-09T10:20:30+0000","end":"2001-10-31T00:00:00+0000"}
See also
https://docs.couchbase.com/server/current/fts/fts-supported-queries-date-range.html server documentation.
Since
1.0.0
Committed
Generally available API and should be preferred in production

Member Function Documentation

◆ date_time_parser()

auto date_time_parser ( std::string parser_name) -> date_range_query&
inline

Enable custom date parser.

Parameters
parser_namename of the custom date parser
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
overridevirtual
Returns
encoded representation of the query.
Since
1.0.0
Internal
Internal interface

Implements search_query.

◆ end() [1/6]

auto end ( std::chrono::system_clock::time_point value) -> date_range_query &

Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.

Parameters
valueend limit time point
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ end() [2/6]

auto end ( std::chrono::system_clock::time_point value,
bool inclusive ) -> date_range_query &

Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.

Parameters
valueend limit time point
inclusivewhether to include limit value into the interval.
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ end() [3/6]

auto end ( std::string value)
inline

Set preformatted date as upper limit.

Parameters
valueend limit formatted as a string, use date_time_parser() for non-standard formats
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ end() [4/6]

auto end ( std::string value,
bool inclusive ) -> date_range_query&
inline

Set preformatted date as upper limit.

Parameters
valueend limit formatted as a string, use date_time_parser() for non-standard formats
inclusivewhether to include limit value into the interval.
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ end() [5/6]

auto end ( std::tm value) -> date_range_query &

Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.

Parameters
valueend limit as a tm (broken down timestamp)
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ end() [6/6]

auto end ( std::tm value,
bool inclusive ) -> date_range_query &

Set upper limit and automatically format so that default date_time parser will be able to parse it on the server.

Parameters
valueend limit as a tm (broken down timestamp)
inclusivewhether to include limit value into the interval.
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ field()

auto field ( std::string field_name) -> date_range_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

◆ start() [1/6]

auto start ( std::chrono::system_clock::time_point value) -> date_range_query &

Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.

Parameters
valuestart limit time point
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ start() [2/6]

auto start ( std::chrono::system_clock::time_point value,
bool inclusive ) -> date_range_query &

Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.

Parameters
valuestart limit time point
inclusivewhether to include limit value into the interval.
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ start() [3/6]

auto start ( std::string value) -> date_range_query&
inline

Set preformatted date as lower limit.

Parameters
valuestart limit formatted as a string, use date_time_parser() for non-standard formats
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ start() [4/6]

auto start ( std::string value,
bool inclusive ) -> date_range_query&
inline

Set preformatted date as lower limit.

Parameters
valuestart limit formatted as a string, use date_time_parser() for non-standard formats
inclusivewhether to include limit value into the interval.
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ start() [5/6]

auto start ( std::tm value) -> date_range_query &

Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.

Parameters
valuestart limit as a tm (broken down timestamp)
Returns
this query for chaining purposes.
Since
1.0.0
Committed
Generally available API and should be preferred in production

◆ start() [6/6]

auto start ( std::tm value,
bool inclusive ) -> date_range_query &

Set lower limit and automatically format so that default date_time parser will be able to parse it on the server.

Parameters
valuestart limit as a tm (broken down timestamp)
inclusivewhether to include limit value into the interval.
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: