Class: Couchbase::Cluster::SearchQuery::DateRangeQuery
- Inherits:
-
Couchbase::Cluster::SearchQuery
- Object
- Couchbase::Cluster::SearchQuery
- Couchbase::Cluster::SearchQuery::DateRangeQuery
- Defined in:
- lib/couchbase/search_options.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/search_options.rb more...
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".freeze
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_json(*args) ⇒ String
Methods inherited from Couchbase::Cluster::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, wildcard
Constructor Details
#initialize {|self| ... } ⇒ DateRangeQuery
Returns a new instance of DateRangeQuery.
357 358 359 360 361 362 363 364 |
# File 'lib/couchbase/search_options.rb', line 357 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
322 323 324 |
# File 'lib/couchbase/search_options.rb', line 322 def boost @boost end |
#date_time_parser ⇒ String
331 332 333 |
# File 'lib/couchbase/search_options.rb', line 331 def date_time_parser @date_time_parser end |
#field ⇒ String
328 329 330 |
# File 'lib/couchbase/search_options.rb', line 328 def field @field end |
#operator ⇒ nil, ...
325 326 327 |
# File 'lib/couchbase/search_options.rb', line 325 def operator @operator 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.
351 352 353 354 |
# File 'lib/couchbase/search_options.rb', line 351 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.
340 341 342 343 |
# File 'lib/couchbase/search_options.rb', line 340 def start_time(time_point, inclusive = nil) @start_time = time_point @start_inclusive = inclusive end |
#to_json(*args) ⇒ String
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/couchbase/search_options.rb', line 369 def to_json(*args) raise ArgumentError, "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["operator"] = operator.to_s if operator 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.to_json(*args) end |