Class: EagleSearch::Interpreter
- Inherits:
-
Object
- Object
- EagleSearch::Interpreter
- Defined in:
- lib/eagle_search/interpreter.rb
Defined Under Namespace
Instance Method Summary collapse
-
#initialize(index, query, options) ⇒ Interpreter
constructor
A new instance of Interpreter.
- #payload ⇒ Object
Constructor Details
#initialize(index, query, options) ⇒ Interpreter
Returns a new instance of Interpreter.
3 4 5 6 7 8 9 |
# File 'lib/eagle_search/interpreter.rb', line 3 def initialize(index, query, ) @index = index @query = query @options = @options[:page] = @options[:page].to_i if @options[:page] @options[:per_page] = @options[:per_page].to_i if @options[:per_page] end |
Instance Method Details
#payload ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eagle_search/interpreter.rb', line 11 def payload return @options[:custom_payload] if @options[:custom_payload] payload = { query: { filtered: { query: query_payload, filter: filter_payload } } } payload.merge!({ sort: @options[:sort] }) if @options[:sort] # from if @options[:page] && @options[:page] > 1 from = (@options[:page] - 1) * (@options[:per_page] || 10) payload.merge!({ from: from }) end #size payload.merge!({ size: @options[:per_page] }) if @options[:per_page] payload end |