Class: Couchbase::SearchQuery::DateRangeQuery
- Inherits:
-
Couchbase::SearchQuery
- Object
- Couchbase::SearchQuery
- Couchbase::SearchQuery::DateRangeQuery
- Defined in:
- lib/couchbase/search_options.rb
Overview
The date range query finds documents containing a date value in the specified field within the specified range.
Constant Summary collapse
- DATE_FORMAT_RFC3339 =
"%Y-%m-%dT%H:%M:%S%:z"
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#end_time(time_point, inclusive = nil) ⇒ Object
Sets the upper boundary of the range.
-
#initialize {|self| ... } ⇒ DateRangeQuery
constructor
A new instance of DateRangeQuery.
-
#start_time(time_point, inclusive = nil) ⇒ Object
Sets the lower boundary of the range.
- #to_h ⇒ Hash<Symbol, #to_json>
Methods inherited from Couchbase::SearchQuery
boolean_field, booleans, conjuncts, date_range, disjuncts, doc_id, geo_bounding_box, geo_distance, geo_polygon, match, match_all, match_none, match_phrase, numeric_range, phrase, prefix, query_string, regexp, term, term_range, #to_json, wildcard
Constructor Details
#initialize {|self| ... } ⇒ DateRangeQuery
Returns a new instance of DateRangeQuery.
398 399 400 401 402 403 404 405 |
# File 'lib/couchbase/search_options.rb', line 398 def initialize super @start_time = nil @start_inclusive = nil @end_time = nil @end_inclusive = nil yield self if block_given? end |
Instance Attribute Details
#boost ⇒ Float
366 367 368 |
# File 'lib/couchbase/search_options.rb', line 366 def boost @boost end |
#date_time_parser ⇒ String
372 373 374 |
# File 'lib/couchbase/search_options.rb', line 372 def date_time_parser @date_time_parser end |
#field ⇒ String
369 370 371 |
# File 'lib/couchbase/search_options.rb', line 369 def field @field end |
Instance Method Details
#end_time(time_point, inclusive = nil) ⇒ Object
Note:
The upper boundary is considered exclusive by default on the server side.
Sets the upper boundary of the range.
392 393 394 395 |
# File 'lib/couchbase/search_options.rb', line 392 def end_time(time_point, inclusive = nil) @end_time = time_point @end_inclusive = inclusive end |
#start_time(time_point, inclusive = nil) ⇒ Object
Note:
The lower boundary is considered inclusive by default on the server side.
Sets the lower boundary of the range.
381 382 383 384 |
# File 'lib/couchbase/search_options.rb', line 381 def start_time(time_point, inclusive = nil) @start_time = time_point @start_inclusive = inclusive end |
#to_h ⇒ Hash<Symbol, #to_json>
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/couchbase/search_options.rb', line 410 def to_h raise Error::InvalidArgument, "either start_time or end_time must be set for DateRangeQuery" if @start_time.nil? && @end_time.nil? data = {} data[:boost] = boost if boost data[:field] = field if field data[:datetime_parser] = date_time_parser if date_time_parser if @start_time data[:start] = if @start_time.respond_to?(:strftime) @start_time.strftime(DATE_FORMAT_RFC3339) else @start_time end data[:inclusive_start] = @start_inclusive unless @start_inclusive.nil? end if @end_time data[:end] = if @end_time.respond_to?(:strftime) @end_time.strftime(DATE_FORMAT_RFC3339) else @end_time end data[:inclusive_end] = @end_inclusive unless @end_inclusive.nil? end data end |