Class: Elasticity::MultiSearchResponseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticity/multi_search_response_parser.rb

Defined Under Namespace

Classes: UnknownError

Class Method Summary collapse

Class Method Details

.error_for(status) ⇒ Object



18
19
20
# File 'lib/elasticity/multi_search_response_parser.rb', line 18

def self.error_for(status)
  Elastic::Transport::Transport::ERRORS[status] || UnknownError
end

.parse(response, search) ⇒ Object

Raises:



5
6
7
8
9
10
11
12
13
14
# File 'lib/elasticity/multi_search_response_parser.rb', line 5

def self.parse(response, search)
  raise error_for(response["status"]), response.to_json if response["error"]

  case
  when search[:documents]
    Search::Results.new(response, search[:search_definition].body, search[:documents].method(:map_hit))
  when search[:active_records]
    Search::ActiveRecordProxy.map_response(search[:active_records], search[:search_definition].body, response)
  end
end