Sha256: 999aad527f2c7520bd3b80aa646f5af6e0e7635d880a2b4d9989593ab30b1629

Contents?: true

Size: 751 Bytes

Versions: 10

Compression:

Stored size: 751 Bytes

Contents

module Elasticsearch
  module Model
    module Response

      # Encapsulates the collection of documents returned from Elasticsearch
      #
      # Implements Enumerable and forwards its methods to the {#results} object.
      #
      class Results
        include Base
        include Enumerable

        delegate :each, :empty?, :size, :slice, :[], :to_a, :to_ary, to: :results

        # @see Base#initialize
        #
        def initialize(klass, response, options={})
          super
        end

        # Returns the {Results} collection
        #
        def results
          # TODO: Configurable custom wrapper
          @results  = response.response['hits']['hits'].map { |hit| Result.new(hit) }
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
elasticsearch-model-queryable-0.1.9 lib/elasticsearch/model/response/results.rb
elasticsearch-model-queryable-0.1.5 lib/elasticsearch/model/response/results.rb
elasticsearch-model-0.1.7 lib/elasticsearch/model/response/results.rb
elasticsearch-model-0.1.6 lib/elasticsearch/model/response/results.rb
elasticsearch-model-0.1.5 lib/elasticsearch/model/response/results.rb
elasticsearch-model-0.1.4 lib/elasticsearch/model/response/results.rb
elasticsearch-model-0.1.3 lib/elasticsearch/model/response/results.rb
elasticsearch-model-0.1.2 lib/elasticsearch/model/response/results.rb
elasticsearch-model-0.1.1 lib/elasticsearch/model/response/results.rb
elasticsearch-model-0.1.0 lib/elasticsearch/model/response/results.rb