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

.parse(response, search) ⇒ Object

Raises:

  • (error_for(response["status"]))


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