Class: Esse::Search::Response
- Inherits:
 - 
      Object
      
        
- Object
 - Esse::Search::Response
 
 
- Extended by:
 - Forwardable
 
- Includes:
 - Enumerable
 
- Defined in:
 - lib/esse/search/response.rb
 
Instance Attribute Summary collapse
- 
  
    
      #options  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute options.
 - 
  
    
      #query  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute query.
 - 
  
    
      #raw_response  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute raw_response.
 
Instance Method Summary collapse
- #aggregations ⇒ Object
 - #hits ⇒ Object
 - 
  
    
      #initialize(query, raw_response, **options)  ⇒ Response 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Response.
 - #shards ⇒ Object
 - #suggestions ⇒ Object
 - #total ⇒ Object
 
Constructor Details
#initialize(query, raw_response, **options) ⇒ Response
Returns a new instance of Response.
      15 16 17 18 19  | 
    
      # File 'lib/esse/search/response.rb', line 15 def initialize(query, raw_response, **) @query = query @raw_response = raw_response @options = end  | 
  
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
      10 11 12  | 
    
      # File 'lib/esse/search/response.rb', line 10 def @options end  | 
  
#query ⇒ Object (readonly)
Returns the value of attribute query.
      10 11 12  | 
    
      # File 'lib/esse/search/response.rb', line 10 def query @query end  | 
  
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
      10 11 12  | 
    
      # File 'lib/esse/search/response.rb', line 10 def raw_response @raw_response end  | 
  
Instance Method Details
#aggregations ⇒ Object
      25 26 27  | 
    
      # File 'lib/esse/search/response.rb', line 25 def aggregations raw_response['aggregations'] end  | 
  
#hits ⇒ Object
      33 34 35  | 
    
      # File 'lib/esse/search/response.rb', line 33 def hits raw_response.dig('hits', 'hits') || [] end  | 
  
#shards ⇒ Object
      21 22 23  | 
    
      # File 'lib/esse/search/response.rb', line 21 def shards raw_response['_shards'] end  | 
  
#suggestions ⇒ Object
      29 30 31  | 
    
      # File 'lib/esse/search/response.rb', line 29 def suggestions raw_response['suggest'] end  | 
  
#total ⇒ Object
      37 38 39 40 41 42 43  | 
    
      # File 'lib/esse/search/response.rb', line 37 def total if raw_response.dig('hits', 'total').respond_to?(:keys) raw_response.dig('hits', 'total', 'value') else raw_response.dig('hits', 'total') end.to_i end  |