Class: Qiita::Elasticsearch::IntToken
- Includes:
- Concerns::RangeOperandIncludable
- Defined in:
- lib/qiita/elasticsearch/int_token.rb
Constant Summary collapse
- INT_PATTERN =
/\A\d+\z/
Constants included from Concerns::RangeOperandIncludable
Concerns::RangeOperandIncludable::RANGE_TERM_REGEXP
Instance Attribute Summary
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, #quoted?
Constructor Details
This class inherits a constructor from Qiita::Elasticsearch::Token
Instance Method Details
#to_hash ⇒ Hash
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/qiita/elasticsearch/int_token.rb', line 14 def to_hash if range_parameter && INT_PATTERN =~ range_query { "range" => { @field_name => { range_parameter => range_query.to_i, }, }, } elsif INT_PATTERN =~ @term { "term" => { @field_name => @term.to_i, }, } else fail InvalidQuery end end |