Class: Sensei::RangeQuery

Inherits:
Query
  • Object
show all
Defined in:
lib/sensei/query.rb

Instance Attribute Summary

Attributes inherited from Query

#options

Instance Method Summary collapse

Methods inherited from Query

construct, #get_boost, #initialize, #not_query?, q, #run, #to_sensei

Methods included from Operators

#&, #*, #boost!, #must_not, #|, #~

Constructor Details

This class inherits a constructor from Sensei::Query

Instance Method Details

#to_hObject



141
142
143
144
145
146
147
148
149
150
# File 'lib/sensei/query.rb', line 141

def to_h
  {:range => {
      options[:field] => {
        :from => options[:from],
        :to => options[:to],
        :_type => options[:type] || ((options[:from].is_a?(Float) || options[:to].is_a?(Float)) ? "double" : "float")
      }.merge(get_boost).merge(options[:type] == :date ? {:_date_format => options[:date_format] || 'YYYY-MM-DD'} : {})
    },
  }
end