Sha256: ee1f5b5187afb22197b56e54868919182a605ae2ae45a4359529e78c6ecaf77d

Contents?: true

Size: 1.74 KB

Versions: 2

Compression:

Stored size: 1.74 KB

Contents

module Elasticsearch
  module API
    module Actions

      # Efficiently iterate over a large result set.
      #
      # When using `from` and `size` to return a large result sets, performance drops as you "paginate" in the set,
      # and you can't guarantee the consistency when the index is being updated at the same time.
      #
      # "Scrolling" the results is frequently used with the `scan` search type.
      #
      # @example Scroll results
      #
      #     result = client.search index: 'scrollindex',
      #                            scroll: '5m',
      #                            body: { query: { match: { title: 'test' } }, sort: '_id' }
      #
      #     client.scroll scroll: '5m', scroll_id: result['_scroll_id']
      #
      # @option arguments [String] :scroll_id The scroll ID
      # @option arguments [Hash] :body The scroll ID if not passed by URL or query parameter.
      # @option arguments [Duration] :scroll Specify how long a consistent view of the index
      #                                      should be maintained for scrolled search
      # @option arguments [String] :scroll_id The scroll ID for scrolled search
      #
      # @see http://www.elasticsearch.org/guide/reference/api/search/scroll/
      # @see http://www.elasticsearch.org/guide/reference/api/search/search-type/
      #
      def scroll(arguments={})
        method = 'GET'
        path   = "_search/scroll"
        params = arguments.select do |k,v|
          [ :scroll,
            :scroll_id ].include?(k)
        end
        # Normalize Ruby 1.8 and Ruby 1.9 Hash#select behaviour
        params = Hash[params] unless params.is_a?(Hash)
        body   = arguments[:body]

        perform_request(method, path, params, body).body
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elasticsearch-api-0.4.0 lib/elasticsearch/api/actions/scroll.rb
elasticsearch-api-0.0.2 lib/elasticsearch/api/actions/scroll.rb