Module: Elasticsearch::API::QueryRules::Actions

Defined in:
lib/elasticsearch/api/actions/query_rules/test.rb,
lib/elasticsearch/api/actions/query_rules/get_rule.rb,
lib/elasticsearch/api/actions/query_rules/put_rule.rb,
lib/elasticsearch/api/actions/query_rules/delete_rule.rb,
lib/elasticsearch/api/actions/query_rules/get_ruleset.rb,
lib/elasticsearch/api/actions/query_rules/put_ruleset.rb,
lib/elasticsearch/api/actions/query_rules/list_rulesets.rb,
lib/elasticsearch/api/actions/query_rules/delete_ruleset.rb

Instance Method Summary collapse

Instance Method Details

#delete_rule(arguments = {}) ⇒ Object

Delete a query rule. Delete a query rule within a query ruleset. This is a destructive action that is only recoverable by re-adding the same rule with the create or update query rule API.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset containing the rule to delete (Required)

  • :rule_id (String)

    The unique identifier of the query rule within the specified ruleset to delete (Required)

  • :error_trace (Boolean)

    When set to ‘true` Elasticsearch will include the full stack trace of errors when they occur.

  • :filter_path (String, Array<String>)

    Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.

  • :human (Boolean)

    When set to ‘true` will return statistics in a format suitable for humans. For example `“exists_time”: “1h”` for humans and `“exists_time_in_millis”: 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines.

  • :pretty (Boolean)

    If set to ‘true` the returned JSON will be “pretty-formatted”. Only use this option for debugging only.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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
# File 'lib/elasticsearch/api/actions/query_rules/delete_rule.rb', line 46

def delete_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.delete_rule' }

  defined_params = [:ruleset_id, :rule_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]
  raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _ruleset_id = arguments.delete(:ruleset_id)

  _rule_id = arguments.delete(:rule_id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_query_rules/#{Utils.listify(_ruleset_id)}/_rule/#{Utils.listify(_rule_id)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#delete_ruleset(arguments = {}) ⇒ Object

Delete a query ruleset. Remove a query ruleset and its associated data. This is a destructive action that is not recoverable.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset to delete (Required)

  • :error_trace (Boolean)

    When set to ‘true` Elasticsearch will include the full stack trace of errors when they occur.

  • :filter_path (String, Array<String>)

    Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.

  • :human (Boolean)

    When set to ‘true` will return statistics in a format suitable for humans. For example `“exists_time”: “1h”` for humans and `“exists_time_in_millis”: 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines.

  • :pretty (Boolean)

    If set to ‘true` the returned JSON will be “pretty-formatted”. Only use this option for debugging only.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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
77
# File 'lib/elasticsearch/api/actions/query_rules/delete_ruleset.rb', line 45

def delete_ruleset(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.delete_ruleset' }

  defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _ruleset_id = arguments.delete(:ruleset_id)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_query_rules/#{Utils.listify(_ruleset_id)}"
  params = Utils.process_params(arguments)

  if Array(arguments[:ignore]).include?(404)
    Utils.rescue_from_not_found do
      Elasticsearch::API::Response.new(
        perform_request(method, path, params, body, headers, request_opts)
      )
    end
  else
    Elasticsearch::API::Response.new(
      perform_request(method, path, params, body, headers, request_opts)
    )
  end
end

#get_rule(arguments = {}) ⇒ Object

Get a query rule. Get details about a query rule within a query ruleset.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset containing the rule to retrieve (Required)

  • :rule_id (String)

    The unique identifier of the query rule within the specified ruleset to retrieve (Required)

  • :error_trace (Boolean)

    When set to ‘true` Elasticsearch will include the full stack trace of errors when they occur.

  • :filter_path (String, Array<String>)

    Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.

  • :human (Boolean)

    When set to ‘true` will return statistics in a format suitable for humans. For example `“exists_time”: “1h”` for humans and `“exists_time_in_millis”: 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines.

  • :pretty (Boolean)

    If set to ‘true` the returned JSON will be “pretty-formatted”. Only use this option for debugging only.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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
# File 'lib/elasticsearch/api/actions/query_rules/get_rule.rb', line 45

def get_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.get_rule' }

  defined_params = [:ruleset_id, :rule_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]
  raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _ruleset_id = arguments.delete(:ruleset_id)

  _rule_id = arguments.delete(:rule_id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_query_rules/#{Utils.listify(_ruleset_id)}/_rule/#{Utils.listify(_rule_id)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#get_ruleset(arguments = {}) ⇒ Object

Get a query ruleset. Get details about a query ruleset.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset (Required)

  • :error_trace (Boolean)

    When set to ‘true` Elasticsearch will include the full stack trace of errors when they occur.

  • :filter_path (String, Array<String>)

    Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.

  • :human (Boolean)

    When set to ‘true` will return statistics in a format suitable for humans. For example `“exists_time”: “1h”` for humans and `“exists_time_in_millis”: 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines.

  • :pretty (Boolean)

    If set to ‘true` the returned JSON will be “pretty-formatted”. Only use this option for debugging only.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



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
# File 'lib/elasticsearch/api/actions/query_rules/get_ruleset.rb', line 44

def get_ruleset(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.get_ruleset' }

  defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _ruleset_id = arguments.delete(:ruleset_id)

  method = Elasticsearch::API::HTTP_GET
  path   = "_query_rules/#{Utils.listify(_ruleset_id)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#list_rulesets(arguments = {}) ⇒ Object

Get all query rulesets. Get summarized information about the query rulesets.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :from (Integer)

    The offset from the first result to fetch. Server default: 0.

  • :size (Integer)

    The maximum number of results to retrieve.

  • :error_trace (Boolean)

    When set to ‘true` Elasticsearch will include the full stack trace of errors when they occur.

  • :filter_path (String, Array<String>)

    Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.

  • :human (Boolean)

    When set to ‘true` will return statistics in a format suitable for humans. For example `“exists_time”: “1h”` for humans and `“exists_time_in_millis”: 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines.

  • :pretty (Boolean)

    If set to ‘true` the returned JSON will be “pretty-formatted”. Only use this option for debugging only.

  • :headers (Hash)

    Custom HTTP headers

See Also:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/elasticsearch/api/actions/query_rules/list_rulesets.rb', line 45

def list_rulesets(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.list_rulesets' }

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  method = Elasticsearch::API::HTTP_GET
  path   = '_query_rules'
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#put_rule(arguments = {}) ⇒ Object

Create or update a query rule. Create or update a query rule within a query ruleset. IMPORTANT: Due to limitations within pinned queries, you can only pin documents using ids or docs, but cannot use both in single rule. It is advised to use one or the other in query rulesets, to avoid errors. Additionally, pinned queries have a maximum limit of 100 pinned hits. If multiple matching rules pin more than 100 documents, only the first 100 documents are pinned in the order they are specified in the ruleset.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset containing the rule to be created or updated. (Required)

  • :rule_id (String)

    The unique identifier of the query rule within the specified ruleset to be created or updated. (Required)

  • :error_trace (Boolean)

    When set to ‘true` Elasticsearch will include the full stack trace of errors when they occur.

  • :filter_path (String, Array<String>)

    Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.

  • :human (Boolean)

    When set to ‘true` will return statistics in a format suitable for humans. For example `“exists_time”: “1h”` for humans and `“exists_time_in_millis”: 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines.

  • :pretty (Boolean)

    If set to ‘true` the returned JSON will be “pretty-formatted”. Only use this option for debugging only.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    request body

Raises:

  • (ArgumentError)

See Also:



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
77
78
# File 'lib/elasticsearch/api/actions/query_rules/put_rule.rb', line 50

def put_rule(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.put_rule' }

  defined_params = [:ruleset_id, :rule_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]
  raise ArgumentError, "Required argument 'rule_id' missing" unless arguments[:rule_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _ruleset_id = arguments.delete(:ruleset_id)

  _rule_id = arguments.delete(:rule_id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_query_rules/#{Utils.listify(_ruleset_id)}/_rule/#{Utils.listify(_rule_id)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#put_ruleset(arguments = {}) ⇒ Object

Create or update a query ruleset. There is a limit of 100 rules per ruleset. This limit can be increased by using the ‘xpack.applications.rules.max_rules_per_ruleset` cluster setting. IMPORTANT: Due to limitations within pinned queries, you can only select documents using `ids` or `docs`, but cannot use both in single rule. It is advised to use one or the other in query rulesets, to avoid errors. Additionally, pinned queries have a maximum limit of 100 pinned hits. If multiple matching rules pin more than 100 documents, only the first 100 documents are pinned in the order they are specified in the ruleset.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset to be created or updated. (Required)

  • :error_trace (Boolean)

    When set to ‘true` Elasticsearch will include the full stack trace of errors when they occur.

  • :filter_path (String, Array<String>)

    Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.

  • :human (Boolean)

    When set to ‘true` will return statistics in a format suitable for humans. For example `“exists_time”: “1h”` for humans and `“exists_time_in_millis”: 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines.

  • :pretty (Boolean)

    If set to ‘true` the returned JSON will be “pretty-formatted”. Only use this option for debugging only.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    request body

Raises:

  • (ArgumentError)

See Also:



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
# File 'lib/elasticsearch/api/actions/query_rules/put_ruleset.rb', line 50

def put_ruleset(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.put_ruleset' }

  defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _ruleset_id = arguments.delete(:ruleset_id)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_query_rules/#{Utils.listify(_ruleset_id)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#test(arguments = {}) ⇒ Object

Test a query ruleset. Evaluate match criteria against a query ruleset to identify the rules that would match that criteria.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :ruleset_id (String)

    The unique identifier of the query ruleset to be created or updated (Required)

  • :error_trace (Boolean)

    When set to ‘true` Elasticsearch will include the full stack trace of errors when they occur.

  • :filter_path (String, Array<String>)

    Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.

  • :human (Boolean)

    When set to ‘true` will return statistics in a format suitable for humans. For example `“exists_time”: “1h”` for humans and `“exists_time_in_millis”: 3600000` for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines.

  • :pretty (Boolean)

    If set to ‘true` the returned JSON will be “pretty-formatted”. Only use this option for debugging only.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    request body

Raises:

  • (ArgumentError)

See Also:



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
# File 'lib/elasticsearch/api/actions/query_rules/test.rb', line 45

def test(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'query_rules.test' }

  defined_params = [:ruleset_id].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'ruleset_id' missing" unless arguments[:ruleset_id]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _ruleset_id = arguments.delete(:ruleset_id)

  method = Elasticsearch::API::HTTP_POST
  path   = "_query_rules/#{Utils.listify(_ruleset_id)}/_test"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end