Class: Stretchy::Results::NullResults

Inherits:
Base
  • Object
show all
Defined in:
lib/stretchy/results/null_results.rb

Instance Attribute Summary

Attributes inherited from Base

#base, #index_name

Instance Method Summary collapse

Methods inherited from Base

#aggregations, #explanations, #hits, #ids, #max_score, #scores, #shards, #took, #total, #total_pages

Constructor Details

#initialize(clause = nil) ⇒ NullResults

use this class when you don't want to actually run a search, or catch an exception or something



9
10
11
12
13
# File 'lib/stretchy/results/null_results.rb', line 9

def initialize(clause = nil)
  @clause       = clause
  @index_name   = clause.index_name if clause.is_a?(Stretchy::Clauses::Base)
  @index_name ||= Stretchy.index_name
end

Instance Method Details

#limitObject



19
20
21
# File 'lib/stretchy/results/null_results.rb', line 19

def limit
  0
end

#offsetObject



23
24
25
# File 'lib/stretchy/results/null_results.rb', line 23

def offset
  0
end

#requestObject



15
16
17
# File 'lib/stretchy/results/null_results.rb', line 15

def request
  {}
end

#responseObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/stretchy/results/null_results.rb', line 27

def response
  @response ||= {
    'took'      => 0,
    'timed_out' => false,
    '_shards'   => {},
    'hits'      => {
      'total'     => 0,
      'max_score' => 0,
      'hits'      => []
    }
  }
end