Movatterモバイル変換


[0]ホーム

URL:


Notice  The highest tagged major version isv9.

termvectors

package
v8.19.1Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License:Apache-2.0Imports:13Imported by:4

Details

Repository

github.com/elastic/go-elasticsearch

Links

Documentation

Overview

Get term vector information.

Get information and statistics about terms in the fields of a particulardocument.

You can retrieve term vectors for documents stored in the index or forartificial 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 allfields 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 computedon the fly if possible.Additionally, term vectors could be computed for documents not even existingin the index, but instead provided by the user.

> warn> Start and end offsets assume UTF-16 encoding is being used. If you want touse these offsets in order to get the original text that produced this token,you should make sure that the string you are taking a sub-string of is alsoencoded using UTF-16.

**Behaviour**

The term and field statistics are not accurate.Deleted documents are not taken into account.The information is only retrieved for the shard the requested documentresides in.The term and field statistics are therefore only useful as relative measureswhereas the absolute numbers have no meaning in this context.By default, when requesting term vectors of artificial documents, a shard toget the statistics from is randomly selected.Use `routing` only to hit a particular shard.

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildPath =errors.New("cannot build path, check for missing path parameters")

ErrBuildPath is returned in case of missing parameters within the build of the request.

Functions

This section is empty.

Types

typeNewTermvectors

type NewTermvectors func(indexstring) *Termvectors

NewTermvectors type alias for index.

funcNewTermvectorsFunc

func NewTermvectorsFunc(tpelastictransport.Interface)NewTermvectors

NewTermvectorsFunc returns a new instance of Termvectors with the provided transport.Used in the index of the library this allows to retrieve every apis in once place.

typeRequest

type Request struct {// Doc An artificial document (a document not present in the index) for which you// want to retrieve term vectors.Docjson.RawMessage `json:"doc,omitempty"`// FieldStatistics If `true`, the response includes://// * The document count (how many documents contain this field).// * The sum of document frequencies (the sum of document frequencies for all// terms in this field).// * The sum of total term frequencies (the sum of total term frequencies of// each term in this field).FieldStatistics *bool `json:"field_statistics,omitempty"`// Fields A list of fields to include in the statistics.// It is used as the default list unless a specific field list is provided in// the `completion_fields` or `fielddata_fields` parameters.Fields []string `json:"fields,omitempty"`// Filter Filter terms based on their tf-idf scores.// This could be useful in order find out a good characteristic vector of a// document.// This feature works in a similar manner to the second phase of the More Like// This Query.Filter *types.TermVectorsFilter `json:"filter,omitempty"`// Offsets If `true`, the response includes term offsets.Offsets *bool `json:"offsets,omitempty"`// Payloads If `true`, the response includes term payloads.Payloads *bool `json:"payloads,omitempty"`// PerFieldAnalyzer Override the default per-field analyzer.// This is useful in order to generate term vectors in any fashion, especially// when using artificial documents.// When providing an analyzer for a field that already stores term vectors, the// term vectors will be regenerated.PerFieldAnalyzer map[string]string `json:"per_field_analyzer,omitempty"`// Positions If `true`, the response includes term positions.Positions *bool `json:"positions,omitempty"`// Routing A custom value that is used to route operations to a specific shard.Routing *string `json:"routing,omitempty"`// TermStatistics If `true`, the response includes://// * The total term frequency (how often a term occurs in all documents).// * The document frequency (the number of documents containing the current// term).//// By default these values are not returned since term statistics can have a// serious performance impact.TermStatistics *bool `json:"term_statistics,omitempty"`// Version If `true`, returns the document version as part of a hit.Version *int64 `json:"version,omitempty"`// VersionType The version type.VersionType *versiontype.VersionType `json:"version_type,omitempty"`}

Request holds the request body struct for the package termvectors

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/_global/termvectors/TermVectorsRequest.ts#L33-L239

funcNewRequestadded inv8.5.0

func NewRequest() *Request

NewRequest returns a Request

func (*Request)FromJSONadded inv8.5.0

func (r *Request) FromJSON(datastring) (*Request,error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request)UnmarshalJSONadded inv8.18.0

func (s *Request) UnmarshalJSON(data []byte)error

typeResponseadded inv8.7.0

type Response struct {Foundbool                        `json:"found"`Id_         *string                     `json:"_id,omitempty"`Index_string                      `json:"_index"`TermVectors map[string]types.TermVector `json:"term_vectors,omitempty"`Tookint64                       `json:"took"`Version_int64                       `json:"_version"`}

Response holds the response body struct for the package termvectors

https://github.com/elastic/elasticsearch-specification/blob/470b4b9aaaa25cae633ec690e54b725c6fc939c7/specification/_global/termvectors/TermVectorsResponse.ts#L25-L34

funcNewResponseadded inv8.7.0

func NewResponse() *Response

NewResponse returns a Response

typeTermvectors

type Termvectors struct {// contains filtered or unexported fields}

funcNew

Get term vector information.

Get information and statistics about terms in the fields of a particulardocument.

You can retrieve term vectors for documents stored in the index or forartificial 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 allfields 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 computedon the fly if possible.Additionally, term vectors could be computed for documents not even existingin the index, but instead provided by the user.

> warn> Start and end offsets assume UTF-16 encoding is being used. If you want touse these offsets in order to get the original text that produced this token,you should make sure that the string you are taking a sub-string of is alsoencoded using UTF-16.

**Behaviour**

The term and field statistics are not accurate.Deleted documents are not taken into account.The information is only retrieved for the shard the requested documentresides in.The term and field statistics are therefore only useful as relative measureswhereas the absolute numbers have no meaning in this context.By default, when requesting term vectors of artificial documents, a shard toget the statistics from is randomly selected.Use `routing` only to hit a particular shard.

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html

func (Termvectors)Do

func (rTermvectors) Do(providedCtxcontext.Context) (*Response,error)

Do runs the request through the transport, handle the response and returns a termvectors.Response

func (*Termvectors)Docadded inv8.9.0

func (r *Termvectors) Doc(docany) *Termvectors

Doc An artificial document (a document not present in the index) for which youwant to retrieve term vectors.API name: doc

doc should be a json.RawMessage or a structureif a structure is provided, the client will defer a json serializationprior to sending the payload to Elasticsearch.

func (*Termvectors)ErrorTraceadded inv8.14.0

func (r *Termvectors) ErrorTrace(errortracebool) *Termvectors

ErrorTrace When set to `true` Elasticsearch will include the full stack trace of errorswhen they occur.API name: error_trace

func (*Termvectors)FieldStatistics

func (r *Termvectors) FieldStatistics(fieldstatisticsbool) *Termvectors

FieldStatistics If `true`, the response includes:

* The document count (how many documents contain this field).* The sum of document frequencies (the sum of document frequencies for allterms in this field).* The sum of total term frequencies (the sum of total term frequencies ofeach term in this field).API name: field_statistics

func (*Termvectors)Fields

func (r *Termvectors) Fields(fields ...string) *Termvectors

Fields A list of fields to include in the statistics.It is used as the default list unless a specific field list is provided inthe `completion_fields` or `fielddata_fields` parameters.API name: fields

func (*Termvectors)Filteradded inv8.9.0

func (r *Termvectors) Filter(filter *types.TermVectorsFilter) *Termvectors

Filter Filter terms based on their tf-idf scores.This could be useful in order find out a good characteristic vector of adocument.This feature works in a similar manner to the second phase of the More LikeThis Query.API name: filter

func (*Termvectors)FilterPathadded inv8.14.0

func (r *Termvectors) FilterPath(filterpaths ...string) *Termvectors

FilterPath Comma-separated list of filters in dot notation which reduce the responsereturned by Elasticsearch.API name: filter_path

func (*Termvectors)Header

func (r *Termvectors) Header(key, valuestring) *Termvectors

Header set a key, value pair in the Termvectors headers map.

func (*Termvectors)HttpRequest

func (r *Termvectors) HttpRequest(ctxcontext.Context) (*http.Request,error)

HttpRequest returns the http.Request object built from thegiven parameters.

func (*Termvectors)Humanadded inv8.14.0

func (r *Termvectors) Human(humanbool) *Termvectors

Human When set to `true` will return statistics in a format suitable for humans.For example `"exists_time": "1h"` for humans and`"eixsts_time_in_millis": 3600000` for computers. When disabled the humanreadable values will be omitted. This makes sense for responses beingconsumedonly by machines.API name: human

func (*Termvectors)Id

func (r *Termvectors) Id(idstring) *Termvectors

Id A unique identifier for the document.API Name: id

func (*Termvectors)Offsets

func (r *Termvectors) Offsets(offsetsbool) *Termvectors

Offsets If `true`, the response includes term offsets.API name: offsets

func (*Termvectors)Payloads

func (r *Termvectors) Payloads(payloadsbool) *Termvectors

Payloads If `true`, the response includes term payloads.API name: payloads

func (*Termvectors)PerFieldAnalyzeradded inv8.9.0

func (r *Termvectors) PerFieldAnalyzer(perfieldanalyzer map[string]string) *Termvectors

PerFieldAnalyzer Override the default per-field analyzer.This is useful in order to generate term vectors in any fashion, especiallywhen using artificial documents.When providing an analyzer for a field that already stores term vectors, theterm vectors will be regenerated.API name: per_field_analyzer

func (Termvectors)Performadded inv8.7.0

func (rTermvectors) Perform(providedCtxcontext.Context) (*http.Response,error)

Perform runs the http.Request through the provided transport and returns an http.Response.

func (*Termvectors)Positions

func (r *Termvectors) Positions(positionsbool) *Termvectors

Positions If `true`, the response includes term positions.API name: positions

func (*Termvectors)Preference

func (r *Termvectors) Preference(preferencestring) *Termvectors

Preference The node or shard the operation should be performed on.It is random by default.API name: preference

func (*Termvectors)Prettyadded inv8.14.0

func (r *Termvectors) Pretty(prettybool) *Termvectors

Pretty If set to `true` the returned JSON will be "pretty-formatted". Only usethis option for debugging only.API name: pretty

func (*Termvectors)Raw

func (r *Termvectors) Raw(rawio.Reader) *Termvectors

Raw takes a json payload as input which is then passed to the http.RequestIf specified Raw takes precedence on Request method.

func (*Termvectors)Realtime

func (r *Termvectors) Realtime(realtimebool) *Termvectors

Realtime If true, the request is real-time as opposed to near-real-time.API name: realtime

func (*Termvectors)Request

func (r *Termvectors) Request(req *Request) *Termvectors

Request allows to set the request property with the appropriate payload.

func (*Termvectors)Routing

func (r *Termvectors) Routing(routingstring) *Termvectors

Routing A custom value that is used to route operations to a specific shard.API name: routing

func (*Termvectors)TermStatistics

func (r *Termvectors) TermStatistics(termstatisticsbool) *Termvectors

TermStatistics If `true`, the response includes:

* The total term frequency (how often a term occurs in all documents).* The document frequency (the number of documents containing the currentterm).

By default these values are not returned since term statistics can have aserious performance impact.API name: term_statistics

func (*Termvectors)Version

func (r *Termvectors) Version(versionnumberint64) *Termvectors

Version If `true`, returns the document version as part of a hit.API name: version

func (*Termvectors)VersionType

func (r *Termvectors) VersionType(versiontypeversiontype.VersionType) *Termvectors

VersionType The version type.API name: version_type

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp