Class: Qiita::Elasticsearch::DateToken
- Includes:
- Concerns::RangeOperandIncludable
- Defined in:
- lib/qiita/elasticsearch/date_token.rb
Constant Summary collapse
- DATE_PATTERN =
Note:
Matches to “YYYY”, “YYYY-MM” and “YYYY-MM-DD”
/\A (?<year>\d{4}) (?: - (?<month>\d{1,2}) (?: - (?<day>\d{1,2}) )? )? \z/x
- FIELD_NAMES_TABLE =
{ "created" => "created_at", "updated" => "updated_at", }
Constants included from Concerns::RangeOperandIncludable
Concerns::RangeOperandIncludable::RANGE_TERM_REGEXP
Instance Attribute Summary collapse
-
#time_zone ⇒ Object
writeonly
Sets the attribute time_zone.
Attributes inherited from Token
Instance Method Summary collapse
Methods inherited from Token
#downcased?, #downcased_term, #filter?, #initialize, #must?, #must_not?, #negative?, #or?, #positive?, #proper_cased_term, #query?, #quoted?, #sort?, #to_s, #type?
Constructor Details
This class inherits a constructor from Qiita::Elasticsearch::Token
Instance Attribute Details
#time_zone=(value) ⇒ Object (writeonly)
Sets the attribute time_zone
29 30 31 |
# File 'lib/qiita/elasticsearch/date_token.rb', line 29 def time_zone=(value) @time_zone = value end |
Instance Method Details
#to_hash ⇒ Hash
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/qiita/elasticsearch/date_token.rb', line 33 def to_hash if date_match if range_parameter { "range" => { converted_field_name => { range_parameter => range_query, "time_zone" => @time_zone, }.reject do |key, value| key == "time_zone" && value.nil? end, }, } else { "range" => { converted_field_name => { "gte" => beginning_of_range.to_s, "lt" => end_of_range.to_s, "time_zone" => @time_zone, }.reject do |key, value| key == "time_zone" && value.nil? end, }, } end else Nodes::NullNode.new.to_hash end end |