Sha256: 0a4026d59a9e30a53e3fb730fbca78b2b17f55965bbde34f88c4025756549cfd

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 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

      def indices
        @index || []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
proxes-0.10.1 lib/proxes/request/search.rb