Method: OpenSearch::API::Actions#get_source

Defined in:
lib/opensearch/api/actions/get_source.rb

#get_source(arguments = {}) ⇒ Object

Returns the source of a document.

*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):

  • :id (String)

    The document ID

  • :index (String)

    The name of the index

  • :preference (String)

    Specify the node or shard the operation should be performed on (default: random)

  • :realtime (Boolean)

    Specify whether to perform the operation in realtime or search mode

  • :refresh (Boolean)

    Refresh the shard containing the document before performing the operation

  • :routing (String)

    Specific routing value

  • :_source (List)

    True or false to return the _source field or not, or a list of fields to return

  • :_source_excludes (List)

    A list of fields to exclude from the returned _source field

  • :_source_includes (List)

    A list of fields to extract and return from the _source field

  • :version (Number)

    Explicit version number for concurrency control

  • :version_type (String)

    Specific version type (options: internal, external, external_gte, force)

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/opensearch/api/actions/get_source.rb', line 51

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

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

  arguments = arguments.clone

  _id = arguments.delete(:id)

  _index = arguments.delete(:index)

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

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