Class: AliyunOpenSearch::Scan

Inherits:
Base
  • Object
show all
Defined in:
lib/aliyun_open_search/scan.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#base_url, #basic_params

Instance Method Summary collapse

Methods inherited from Base

basic_params, escape, format_params, signature, signature_nonce, #uri

Constructor Details

#initialize(index_names, options = {}) ⇒ Scan

Returns a new instance of Scan.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/aliyun_open_search/scan.rb', line 5

def initialize(index_names, options = {})
  super()

  @index_names = index_names.is_a?(Array) ? index_names.join(";") : index_names
  @scroll = options[:scroll] || "1m"

  @custom_params = {
    query: [
      options[:query] || "query=''",
      "config=hit:#{options[:hit] || 500},format:#{options[:format] || "json"}"
    ]
  }

  setup
end

Instance Attribute Details

#custom_paramsObject (readonly)

Returns the value of attribute custom_params.



3
4
5
# File 'lib/aliyun_open_search/scan.rb', line 3

def custom_params
  @custom_params
end

#request_idObject (readonly)

Returns the value of attribute request_id.



3
4
5
# File 'lib/aliyun_open_search/scan.rb', line 3

def request_id
  @request_id
end

#resultObject (readonly)

Returns the value of attribute result.



3
4
5
# File 'lib/aliyun_open_search/scan.rb', line 3

def result
  @result
end

#scroll_idObject (readonly)

Returns the value of attribute scroll_id.



3
4
5
# File 'lib/aliyun_open_search/scan.rb', line 3

def scroll_id
  @scroll_id
end

Instance Method Details

#executeObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/aliyun_open_search/scan.rb', line 35

def execute
  params = Base.new.basic_params.merge(
    Base.format_params(
      custom_params.merge(
        "index_name" => @index_names,
        "scroll" => @scroll,
        "scroll_id" => @scroll_id
      )
    )
  )

  send_request(params)
end

#setupObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/aliyun_open_search/scan.rb', line 21

def setup
  params = basic_params.merge(
    Base.format_params(
      custom_params.merge(
        "index_name" => @index_names,
        "scroll" => @scroll,
        "search_type" => "scan"
      )
    )
  )

  send_request(params)
end