Sha256: 271502068054a07911870bfdfd6280138c476d92e3347ebfc630e8774699fb84

Contents?: true

Size: 1.82 KB

Versions: 14

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

module Esse
  class Transport
    module InstanceMethods
      # Returns results matching a query.
      # @param [Hash] options
      # @option [String] :index The comma-separated list of index names to search; use `_all` to perform the operation on all indices
      def search(index:, **options)
        definition = options.merge(
          index: index,
        )

        Esse::Events.instrument('elasticsearch.search') do |payload|
          payload[:request] = definition
          payload[:response] = coerce_exception { client.search(definition) }
        end
      end

      # Allows to retrieve a large numbers of results from a single search request.
      #
      # @param [Hash] options
      # @option [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
      # @option [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response
      # @option [Hash] :body The scroll ID
      def scroll(scroll:, **definition)
        unless definition[:body]
          raise ArgumentError, 'scroll search must have a :body with the :scroll_id'
        end
        Esse::Events.instrument('elasticsearch.search') do |payload|
          payload[:request] = definition
          payload[:response] = coerce_exception { client.scroll(scroll: scroll, **definition) }
        end
      end

      # Explicitly clears the search context for a scroll.
      #
      # @param [Hash] options
      # @option [Hash] :body Body with the "scroll_id" (string or array of strings) Scroll IDs to clear.
      #   To clear all scroll IDs, use _all.
      def clear_scroll(body:, **options)
        coerce_exception { client.clear_scroll(body: body, **options) }
      end
    end

    include InstanceMethods
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
esse-0.4.0.rc4 lib/esse/transport/search.rb
esse-0.4.0.rc3 lib/esse/transport/search.rb
esse-0.4.0.rc2 lib/esse/transport/search.rb
esse-0.4.0.rc1 lib/esse/transport/search.rb
esse-0.3.5 lib/esse/transport/search.rb
esse-0.3.4 lib/esse/transport/search.rb
esse-0.3.3 lib/esse/transport/search.rb
esse-0.3.2 lib/esse/transport/search.rb
esse-0.3.1 lib/esse/transport/search.rb
esse-0.3.0 lib/esse/transport/search.rb
esse-0.2.6 lib/esse/transport/search.rb
esse-0.2.5 lib/esse/transport/search.rb
esse-0.2.4 lib/esse/transport/search.rb
esse-0.2.3 lib/esse/transport/search.rb