Sha256: 548fb2888f75ea57674557b89f23dfe2f5e422eb81ffa93c27af2527cb1b1402

Contents?: true

Size: 670 Bytes

Versions: 18

Compression:

Stored size: 670 Bytes

Contents

module Elasticity
  class MultiSearchResponseParser
    class UnknownError < StandardError; end

    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

    private

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
es-elasticity-1.0.1 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.14.1 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.14.0 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.14.0.jhumphreys lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.13.5 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.13.5.dblackmon.1 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.13.4 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.13.4.zpesic lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.13.4.dblackmon.1 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.13.4.dblackmon.0 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.13.4.dblackmon lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.13.3 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.13.3.pre1 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.12.0 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.11.5 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.11.1 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.9.0 lib/elasticity/multi_search_response_parser.rb
es-elasticity-0.8.4 lib/elasticity/multi_search_response_parser.rb