Class: Qiita::Elasticsearch::RangeToken

Inherits:
Token
  • Object
show all
Defined in:
lib/qiita/elasticsearch/range_token.rb

Constant Summary collapse

RANGE_TERM_REGEXP =
/\A(?<operand>\<=|\<|\>=|\>)(?<query>.*)\z/

Instance Attribute Summary

Attributes inherited from Token

#field_name, #options, #term

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 Method Details

#to_hashHash

Returns:

  • (Hash)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/qiita/elasticsearch/range_token.rb', line 9

def to_hash
  if range_parameter
    {
      "range" => {
        @field_name => {
          range_parameter => range_query.to_i,
        },
      },
    }
  else
    {
      "term" => {
        @field_name => proper_cased_term.to_i,
      },
    }
  end
end