Method: Elasticsearch::API::Indices::Actions#get_field_mapping

Defined in:
lib/elasticsearch/api/actions/indices/get_field_mapping.rb

#get_field_mapping(arguments = {}) ⇒ Object

Get mapping definitions. Retrieves mapping definitions for one or more fields. For data streams, the API retrieves field mappings for the stream’s backing indices. This API is useful if you don’t need a complete mapping or if an index mapping contains a large number of fields.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :fields (String, Array<String>)

    Comma-separated list or wildcard expression of fields used to limit returned information. Supports wildcards (‘*`). (Required)

  • :index (String, Array)

    Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (‘*`). To target all data streams and indices, omit this parameter or use `*` or `_all`.

  • :allow_no_indices (Boolean)

    If ‘false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices. This behavior applies even if the request targets other open indices. Server default: true.

  • :expand_wildcards (String, Array<String>)

    Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as ‘open,hidden`. Server default: open.

  • :ignore_unavailable (Boolean)

    If ‘false`, the request returns an error if it targets a missing or closed index.

  • :include_defaults (Boolean)

    If ‘true`, return all default settings in the response.

  • :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:



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/elasticsearch/api/actions/indices/get_field_mapping.rb', line 57

def get_field_mapping(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'indices.get_field_mapping' }

  defined_params = [:fields, :index].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 'fields' missing" unless arguments[:fields]

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

  body = nil

  _fields = arguments.delete(:fields)

  _index = arguments.delete(:index)

  method = Elasticsearch::API::HTTP_GET
  path   = if _index && _fields
             "#{Utils.listify(_index)}/_mapping/field/#{Utils.listify(_fields)}"
           else
             "_mapping/field/#{Utils.listify(_fields)}"
           end
  params = Utils.process_params(arguments)

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