Sha256: 2d3823046e18a1c129bb485a53f66ad4e72820e8a929a3aea62ea3923d8f7cf2

Contents?: true

Size: 960 Bytes

Versions: 17

Compression:

Stored size: 960 Bytes

Contents

# frozen_string_literal: true

require 'proxes/request'
require 'proxes/policies/request/search_policy'

module ProxES
  class Request
    class Search < Request
      attr_reader :index, :type

      def index=(idx)
        @index = idx
        self.path_info = '/' + [index, type, id, endpoint].compact
                                                          .map { |v| v.is_a?(Array) ? v.join(',') : v }
                                                          .select { |v| !v.nil? && v != '' }.join('/')
      end

      def endpoint
        '_search'
      end

      def parse
        @index ||= check_part(path_parts[0]) unless path_parts[0] == endpoint
        @type  ||= check_part(path_parts[1]) unless path_parts[1] == endpoint
        @id    ||= check_part(path_parts[2]) unless path_parts[2] == endpoint
      end

      def id
        @id == [] ? nil : @id
      end

      def indices?
        type != ['scroll']
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
proxes-0.9.13 lib/proxes/request/search.rb
proxes-0.9.12 lib/proxes/request/search.rb
proxes-0.9.9 lib/proxes/request/search.rb
proxes-0.9.7 lib/proxes/request/search.rb
proxes-0.9.4 lib/proxes/request/search.rb
proxes-0.9.2 lib/proxes/request/search.rb
proxes-0.9.1 lib/proxes/request/search.rb
proxes-0.9.0 lib/proxes/request/search.rb
proxes-0.8.6 lib/proxes/request/search.rb
proxes-0.8.5 lib/proxes/request/search.rb
proxes-0.8.4 lib/proxes/request/search.rb
proxes-0.8.3 lib/proxes/request/search.rb
proxes-0.8.2 lib/proxes/request/search.rb
proxes-0.8.1 lib/proxes/request/search.rb
proxes-0.8.0 lib/proxes/request/search.rb
proxes-0.7.1 lib/proxes/request/search.rb
proxes-0.7.0 lib/proxes/request/search.rb