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.
327 328 329 330 331 332 333 334 |
# File 'lib/couchbase/search_options.rb', line 327 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
295 296 297 |
# File 'lib/couchbase/search_options.rb', line 295 def boost @boost end |
#date_time_parser ⇒ String
301 302 303 |
# File 'lib/couchbase/search_options.rb', line 301 def date_time_parser @date_time_parser end |
#field ⇒ String
298 299 300 |
# File 'lib/couchbase/search_options.rb', line 298 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.
321 322 323 324 |
# File 'lib/couchbase/search_options.rb', line 321 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.
310 311 312 313 |
# File 'lib/couchbase/search_options.rb', line 310 def start_time(time_point, inclusive = nil) @start_time = time_point @start_inclusive = inclusive end |
#to_json(*args) ⇒ String
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'lib/couchbase/search_options.rb', line 339 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["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 |