Method: Elasticsearch::API::Actions#termvectors
- Defined in:
- lib/elasticsearch/api/actions/termvectors.rb
#termvectors(arguments = {}) ⇒ Object
Get term vector information. Get information and statistics about terms in the fields of a particular document. You can retrieve term vectors for documents stored in the index or for artificial documents passed in the body of the request. You can specify the fields you are interested in through the ‘fields` parameter or by adding the fields to the request body. For example:
“‘ GET /my-index-000001/_termvectors/1?fields=message “`
Fields can be specified using wildcards, similar to the multi match query. Term vectors are real-time by default, not near real-time. This can be changed by setting ‘realtime` parameter to `false`. You can request three types of values: _term information_, _term statistics_, and _field statistics_. By default, all term information and field statistics are returned for all fields but term statistics are excluded. **Term information**
-
term frequency in the field (always returned)
-
term positions (‘positions: true`)
-
start and end offsets (‘offsets: true`)
-
term payloads (‘payloads: true`), as base64 encoded bytes
If the requested information wasn’t stored in the index, it will be computed on the fly if possible. Additionally, term vectors could be computed for documents not even existing in the index, but instead provided by the user.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/elasticsearch/api/actions/termvectors.rb', line 84 def termvectors(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'termvectors' } defined_params = [:index, :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 'index' missing" unless arguments[:index] arguments = arguments.clone headers = arguments.delete(:headers) || {} body = arguments.delete(:body) _index = arguments.delete(:index) _id = arguments.delete(:id) method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end arguments.delete(:endpoint) path = if _index && _id "#{Utils.listify(_index)}/_termvectors/#{Utils.listify(_id)}" else "#{Utils.listify(_index)}/_termvectors" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |