Module: Elasticsearch::API::Actions

Defined in:
lib/elasticsearch/api/actions/get.rb,
lib/elasticsearch/api/actions/bulk.rb,
lib/elasticsearch/api/actions/info.rb,
lib/elasticsearch/api/actions/mget.rb,
lib/elasticsearch/api/actions/ping.rb,
lib/elasticsearch/api/actions/count.rb,
lib/elasticsearch/api/actions/index.rb,
lib/elasticsearch/api/actions/create.rb,
lib/elasticsearch/api/actions/delete.rb,
lib/elasticsearch/api/actions/exists.rb,
lib/elasticsearch/api/actions/scroll.rb,
lib/elasticsearch/api/actions/search.rb,
lib/elasticsearch/api/actions/update.rb,
lib/elasticsearch/api/actions/explain.rb,
lib/elasticsearch/api/actions/msearch.rb,
lib/elasticsearch/api/actions/reindex.rb,
lib/elasticsearch/api/actions/benchmark.rb,
lib/elasticsearch/api/actions/rank_eval.rb,
lib/elasticsearch/api/actions/field_caps.rb,
lib/elasticsearch/api/actions/get_script.rb,
lib/elasticsearch/api/actions/get_source.rb,
lib/elasticsearch/api/actions/put_script.rb,
lib/elasticsearch/api/actions/termvectors.rb,
lib/elasticsearch/api/actions/clear_scroll.rb,
lib/elasticsearch/api/actions/mtermvectors.rb,
lib/elasticsearch/api/actions/delete_script.rb,
lib/elasticsearch/api/actions/exists_source.rb,
lib/elasticsearch/api/actions/search_shards.rb,
lib/elasticsearch/api/actions/abort_benchmark.rb,
lib/elasticsearch/api/actions/delete_by_query.rb,
lib/elasticsearch/api/actions/params_registry.rb,
lib/elasticsearch/api/actions/search_template.rb,
lib/elasticsearch/api/actions/update_by_query.rb,
lib/elasticsearch/api/actions/msearch_template.rb,
lib/elasticsearch/api/actions/reindex_rethrottle.rb,
lib/elasticsearch/api/actions/delete_by_rethrottle.rb,
lib/elasticsearch/api/actions/render_search_template.rb,
lib/elasticsearch/api/actions/scripts_painless_execute.rb,
lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb,
lib/elasticsearch/api/actions/update_by_query_rethrottle.rb

Defined Under Namespace

Modules: ParamsRegistry

Instance Method Summary collapse

Instance Method Details

#abort_benchmark(arguments = {}) ⇒ Object

Abort a running benchmark

Examples:


client.abort_benchmark name: 'my_benchmark'

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :name (String)

    A benchmark name

See Also:



18
19
20
21
22
23
24
25
# File 'lib/elasticsearch/api/actions/abort_benchmark.rb', line 18

def abort_benchmark(arguments = {})
  method = HTTP_POST
  path   = "_bench/abort/#{arguments[:name]}"
  params = {}
  body   = nil

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

#benchmark(arguments = {}) ⇒ Object

Run a single query, or a set of queries, and return statistics on their performance

Examples:

Return statistics for a single query


client.benchmark body: {
  name: 'my_benchmark',
  competitors: [
    {
      name: 'query_1',
      requests: [
        { query: { match: { _all: 'a*' } } }
      ]
    }
  ]
}

Return statistics for a set of “competing” queries


client.benchmark body: {
  name: 'my_benchmark',
  competitors: [
    {
      name: 'query_a',
      requests: [
        { query: { match: { _all: 'a*' } } }
      ]
    },
    {
      name: 'query_b',
      requests: [
        { query: { match: { _all: 'b*' } } }
      ]
    }
  ]
}

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (List)

    A comma-separated list of index names; use ‘_all` or empty string to perform the operation on all indices

  • :type (String)

    The name of the document type

  • :body (Hash)

    The search definition using the Query DSL

  • :verbose (Boolean)

    Specify whether to return verbose statistics about each iteration (default: false)

See Also:



53
54
55
56
57
58
59
60
# File 'lib/elasticsearch/api/actions/benchmark.rb', line 53

def benchmark(arguments = {})
  method = HTTP_PUT
  path   = "_bench"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
  body   = arguments[:body]

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

#bulk(arguments = {}) ⇒ Object

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The operation definition and data (action-data pairs), separated by newlines (Required)

Raises:

  • (ArgumentError)

See Also:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/elasticsearch/api/actions/bulk.rb', line 28

def bulk(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_bulk"
           elsif _index
             "#{Utils.__listify(_index)}/_bulk"
           else
             "_bulk"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  if body.is_a? Array
    payload = Utils.__bulkify(body)
  else
    payload = body
end

  perform_request(method, path, params, payload, { "Content-Type" => "application/x-ndjson" }).body
end

#clear_scroll(arguments = {}) ⇒ Object

*Deprecation notice*: A scroll id can be quite large and should be specified as part of the body Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter

See Also:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/elasticsearch/api/actions/clear_scroll.rb', line 21

def clear_scroll(arguments = {})
  arguments = arguments.clone

  _scroll_id = arguments.delete(:scroll_id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = if _scroll_id
             "_search/scroll/#{Utils.__listify(_scroll_id)}"
           else
             "_search/scroll"
end
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#count(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    A query to restrict the results specified with the Query DSL (optional)

See Also:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/elasticsearch/api/actions/count.rb', line 40

def count(arguments = {})
  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = if arguments[:body]
             Elasticsearch::API::HTTP_POST
           else
             Elasticsearch::API::HTTP_GET
end

  path = if _index && _type
           "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_count"
         elsif _index
           "#{Utils.__listify(_index)}/_count"
         else
           "_count"
end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#create(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The document (Required)

See Also:



36
37
38
39
40
41
42
# File 'lib/elasticsearch/api/actions/create.rb', line 36

def create(arguments = {})
  if arguments[:id]
    index arguments.update op_type: 'create'
  else
    index arguments
  end
end

#delete(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/elasticsearch/api/actions/delete.rb', line 33

def delete(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_DELETE
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
           else
             "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  if Array(arguments[:ignore]).include?(404)
    Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
  else
    perform_request(method, path, params, body).body
  end
end

#delete_by_query(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The search definition using the Query DSL (Required)

Raises:

  • (ArgumentError)

See Also:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/elasticsearch/api/actions/delete_by_query.rb', line 62

def delete_by_query(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_delete_by_query"
           else
             "#{Utils.__listify(_index)}/_delete_by_query"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#delete_by_query_rethrottle(arguments = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/elasticsearch/api/actions/delete_by_rethrottle.rb', line 15

def delete_by_query_rethrottle(arguments = {})
  raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id]

  method = Elasticsearch::API::HTTP_POST
  path   = "_delete_by_query/#{arguments[:task_id]}/_rethrottle"
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
  body   = nil

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

#delete_script(arguments = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/elasticsearch/api/actions/delete_script.rb', line 17

def delete_script(arguments = {})
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_scripts/#{Utils.__listify(_id)}"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#exists(arguments = {}) ⇒ Object Also known as: exists?

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/elasticsearch/api/actions/exists.rb', line 33

def exists(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_HEAD
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
           else
             "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil

  Utils.__rescue_from_not_found do
    perform_request(method, path, params, body).status == 200 ? true : false
  end
end

#exists_source(arguments = {}) ⇒ Object Also known as: exists_source?

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/elasticsearch/api/actions/exists_source.rb', line 32

def exists_source(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_HEAD
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_source"
           else
             "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#explain(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The query definition using the Query DSL

Raises:

  • (ArgumentError)

See Also:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/elasticsearch/api/actions/explain.rb', line 37

def explain(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_explain"
           else
             "#{Utils.__listify(_index)}/_explain/#{Utils.__listify(_id)}"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#field_caps(arguments = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/elasticsearch/api/actions/field_caps.rb', line 22

def field_caps(arguments = {})
  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index
             "#{Utils.__listify(_index)}/_field_caps"
           else
             "_field_caps"
end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#get(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/elasticsearch/api/actions/get.rb', line 33

def get(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
           else
             "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = nil
  if Array(arguments[:ignore]).include?(404)
    Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
  else
    perform_request(method, path, params, body).body
  end
end

#get_script(arguments = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/elasticsearch/api/actions/get_script.rb', line 16

def get_script(arguments = {})
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_scripts/#{Utils.__listify(_id)}"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#get_source(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/elasticsearch/api/actions/get_source.rb', line 32

def get_source(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_source"
           else
             "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#index(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The document (Required)

Raises:

  • (ArgumentError)

See Also:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/elasticsearch/api/actions/index.rb', line 39

def index(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = _id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
           elsif _index && _id
             "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
           elsif _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}"
           else
             "#{Utils.__listify(_index)}/_doc"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#info(arguments = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/elasticsearch/api/actions/info.rb', line 14

def info(arguments = {})
  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_GET
  path   = ""
  params = {}

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

#mget(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    Document identifiers; can be either ‘docs` (containing full document information) or `ids` (when index and type is provided in the URL. (Required)

Raises:

  • (ArgumentError)

See Also:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/elasticsearch/api/actions/mget.rb', line 30

def mget(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_mget"
           elsif _index
             "#{Utils.__listify(_index)}/_mget"
           else
             "_mget"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#msearch(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The request definitions (metadata-search request definition pairs), separated by newlines (Required)

Raises:

  • (ArgumentError)

See Also:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/elasticsearch/api/actions/msearch.rb', line 31

def msearch(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch"
           elsif _index
             "#{Utils.__listify(_index)}/_msearch"
           else
             "_msearch"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  case
  when body.is_a?(Array) && body.any? { |d| d.has_key? :search }
    payload = body
              .inject([]) do |sum, item|
                meta = item
                data = meta.delete(:search)

                sum << meta
                sum << data
                sum
              end
              .map { |item| Elasticsearch::API.serializer.dump(item) }
    payload << "" unless payload.empty?
    payload = payload.join("
")
  when body.is_a?(Array)
    payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) }
    payload << "" unless payload.empty?
    payload = payload.join("
")
  else
    payload = body
end

  perform_request(method, path, params, payload, { "Content-Type" => "application/x-ndjson" }).body
end

#msearch_template(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The request definitions (metadata-search request definition pairs), separated by newlines (Required)

Raises:

  • (ArgumentError)

See Also:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/elasticsearch/api/actions/msearch_template.rb', line 28

def msearch_template(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_msearch/template"
           elsif _index
             "#{Utils.__listify(_index)}/_msearch/template"
           else
             "_msearch/template"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  case
  when body.is_a?(Array)
    payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) }
    payload << "" unless payload.empty?
    payload = payload.join("
")
  else
    payload = body
end

  perform_request(method, path, params, payload, { "Content-Type" => "application/x-ndjson" }).body
end

#mtermvectors(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/elasticsearch/api/actions/mtermvectors.rb', line 35

def mtermvectors(arguments = {})
  arguments = arguments.clone
  ids = arguments.delete(:ids)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_mtermvectors"
           elsif _index
             "#{Utils.__listify(_index)}/_mtermvectors"
           else
             "_mtermvectors"
end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  if ids
    body = { :ids => ids }
  else
    body = arguments[:body]
    end
  perform_request(method, path, params, body).body
end

#ping(arguments = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/elasticsearch/api/actions/ping.rb', line 14

def ping(arguments = {})
  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_HEAD
  path   = ""
  params = {}

  body = nil
  begin
  perform_request(method, path, params, body).status == 200 ? true : false
  rescue Exception => e
    if e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not *Found|404|ConnectionFailed/i
      false
    else
      raise e
    end
end
end

#put_script(arguments = {}) ⇒ Object

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The document (Required)

Raises:

  • (ArgumentError)

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/elasticsearch/api/actions/put_script.rb', line 20

def put_script(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _context = arguments.delete(:context)

  method = Elasticsearch::API::HTTP_PUT
  path   = if _id && _context
             "_scripts/#{Utils.__listify(_id)}/#{Utils.__listify(_context)}"
           else
             "_scripts/#{Utils.__listify(_id)}"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#rank_eval(arguments = {}) ⇒ Object

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. (Required)

Raises:

  • (ArgumentError)

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/elasticsearch/api/actions/rank_eval.rb', line 20

def rank_eval(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index
             "#{Utils.__listify(_index)}/_rank_eval"
           else
             "_rank_eval"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#reindex(arguments = {}) ⇒ Object

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The search definition using the Query DSL and the prototype for the index request. (Required)

Raises:

  • (ArgumentError)

See Also:



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/elasticsearch/api/actions/reindex.rb', line 25

def reindex(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_POST
  path   = "_reindex"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#reindex_rethrottle(arguments = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/elasticsearch/api/actions/reindex_rethrottle.rb', line 16

def reindex_rethrottle(arguments = {})
  raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id]

  arguments = arguments.clone

  _task_id = arguments.delete(:task_id)

  method = Elasticsearch::API::HTTP_POST
  path   = "_reindex/#{Utils.__listify(_task_id)}/_rethrottle"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#render_search_template(arguments = {}) ⇒ Object

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The search definition template and its params

See Also:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/elasticsearch/api/actions/render_search_template.rb', line 16

def render_search_template(arguments = {})
  arguments = arguments.clone

  _id = arguments.delete(:id)

  method = Elasticsearch::API::HTTP_GET
  path   = if _id
             "_render/template/#{Utils.__listify(_id)}"
           else
             "_render/template"
end
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#scripts_painless_execute(arguments = {}) ⇒ Object

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The script to execute

See Also:



15
16
17
18
19
20
21
22
23
24
# File 'lib/elasticsearch/api/actions/scripts_painless_execute.rb', line 15

def scripts_painless_execute(arguments = {})
  arguments = arguments.clone

  method = Elasticsearch::API::HTTP_GET
  path   = "_scripts/painless/_execute"
  params = {}

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#scroll(arguments = {}) ⇒ Object

*Deprecation notice*: A scroll id can be quite large and should be specified as part of the body Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The scroll ID if not passed by URL or query parameter.

See Also:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/elasticsearch/api/actions/scroll.rb', line 24

def scroll(arguments = {})
  arguments = arguments.clone

  _scroll_id = arguments.delete(:scroll_id)

  method = Elasticsearch::API::HTTP_GET
  path   = if _scroll_id
             "_search/scroll/#{Utils.__listify(_scroll_id)}"
           else
             "_search/scroll"
end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#search(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The search definition using the Query DSL

See Also:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/elasticsearch/api/actions/search.rb', line 72

def search(arguments = {})
  arguments = arguments.clone
  arguments[:index] = UNDERSCORE_ALL if !arguments[:index] && arguments[:type]

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_search"
           elsif _index
             "#{Utils.__listify(_index)}/_search"
           else
             "_search"
end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#search_shards(arguments = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/elasticsearch/api/actions/search_shards.rb', line 22

def search_shards(arguments = {})
  arguments = arguments.clone

  _index = arguments.delete(:index)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index
             "#{Utils.__listify(_index)}/_search_shards"
           else
             "_search_shards"
end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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

#search_template(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The search definition template and its params (Required)

Raises:

  • (ArgumentError)

See Also:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/elasticsearch/api/actions/search_template.rb', line 38

def search_template(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_search/template"
           elsif _index
             "#{Utils.__listify(_index)}/_search/template"
           else
             "_search/template"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#termvector(arguments = {}) ⇒ Object

Deprecated: Use the plural version, #termvectors



67
68
69
# File 'lib/elasticsearch/api/actions/termvectors.rb', line 67

def termvector(arguments = {})
  termvectors(arguments.merge endpoint: '_termvector')
end

#termvectors(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    Define parameters and or supply a document to get termvectors for. See documentation.

Raises:

  • (ArgumentError)

See Also:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/elasticsearch/api/actions/termvectors.rb', line 35

def termvectors(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _id = arguments.delete(:id)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_GET

  endpoint = arguments.delete(:endpoint) || '_termvectors'
  path = if _index && _type && _id
           "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/#{endpoint}"
         elsif _index && _type
           "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{endpoint}"
         elsif _index && _id
           "#{Utils.__listify(_index)}/#{endpoint}/#{Utils.__listify(_id)}"
         else
           "#{Utils.__listify(_index)}/#{endpoint}"
  end

  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#update(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The request definition requires either ‘script` or partial `doc` (Required)

Raises:

  • (ArgumentError)

See Also:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/elasticsearch/api/actions/update.rb', line 36

def update(arguments = {})
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type && _id
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_update"
           else
             "#{Utils.__listify(_index)}/_update/#{Utils.__listify(_id)}"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  if Array(arguments[:ignore]).include?(404)
    Utils.__rescue_from_not_found { perform_request(method, path, params, body).body }
  else
    perform_request(method, path, params, body).body
  end
end

#update_by_query(arguments = {}) ⇒ Object

*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :body (Hash)

    The search definition using the Query DSL

Raises:

  • (ArgumentError)

See Also:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/elasticsearch/api/actions/update_by_query.rb', line 66

def update_by_query(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _type = arguments.delete(:type)

  method = Elasticsearch::API::HTTP_POST
  path   = if _index && _type
             "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_update_by_query"
           else
             "#{Utils.__listify(_index)}/_update_by_query"
  end
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

  body = arguments[:body]
  perform_request(method, path, params, body).body
end

#update_by_query_rethrottle(arguments = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/elasticsearch/api/actions/update_by_query_rethrottle.rb', line 16

def update_by_query_rethrottle(arguments = {})
  raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id]

  arguments = arguments.clone

  _task_id = arguments.delete(:task_id)

  method = Elasticsearch::API::HTTP_POST
  path   = "_update_by_query/#{Utils.__listify(_task_id)}/_rethrottle"
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)

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