Method: OpenSearch::API::Actions#termvectors

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

#termvectors(arguments = {}) ⇒ Object

Returns information and statistics about terms in the fields of a particular 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):

  • :index (String)

    The index in which the document resides. (Required)

  • :id (String)

    The id of the document, when not specified a doc param should be supplied.

  • :term_statistics (Boolean)

    Specifies if total term frequency and document frequency should be returned.

  • :field_statistics (Boolean)

    Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned.

  • :fields (List)

    A comma-separated list of fields to return.

  • :offsets (Boolean)

    Specifies if term offsets should be returned.

  • :positions (Boolean)

    Specifies if term positions should be returned.

  • :payloads (Boolean)

    Specifies if term payloads should be returned.

  • :preference (String)

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

  • :routing (String)

    Specific routing value.

  • :realtime (Boolean)

    Specifies if request is real-time as opposed to near-real-time (default: true).

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

  • :body (Hash)

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

Raises:

  • (ArgumentError)


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
79
80
81
82
# File 'lib/opensearch/api/actions/termvectors.rb', line 54

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

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

  arguments = arguments.clone

  _index = arguments.delete(:index)

  _id = arguments.delete(:id)

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

  endpoint = arguments.delete(:endpoint) || '_termvectors'
  path = if _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, headers).body
end