analyze

package
v8.14.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Performs the analysis process on a text and return the tokens breakdown of the text.

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

type Analyze

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

func New

Performs the analysis process on a text and return the tokens breakdown of the text.

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html

func (*Analyze) Analyzer

func (r *Analyze) Analyzer(analyzer string) *Analyze

Analyzer The name of the analyzer that should be applied to the provided `text`. This could be a built-in analyzer, or an analyzer that’s been configured in the index. API name: analyzer

func (*Analyze) Attributes

func (r *Analyze) Attributes(attributes ...string) *Analyze

Attributes Array of token attributes used to filter the output of the `explain` parameter. API name: attributes

func (*Analyze) CharFilter

func (r *Analyze) CharFilter(charfilters ...types.CharFilter) *Analyze

CharFilter Array of character filters used to preprocess characters before the tokenizer. API name: char_filter

func (Analyze) Do

func (r Analyze) Do(providedCtx context.Context) (*Response, error)

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

func (*Analyze) Explain

func (r *Analyze) Explain(explain bool) *Analyze

Explain If `true`, the response includes token attributes and additional details. API name: explain

func (*Analyze) Field

func (r *Analyze) Field(field string) *Analyze

Field Field used to derive the analyzer. To use this parameter, you must specify an index. If specified, the `analyzer` parameter overrides this value. API name: field

func (*Analyze) Filter

func (r *Analyze) Filter(filters ...types.TokenFilter) *Analyze

Filter Array of token filters used to apply after the tokenizer. API name: filter

func (*Analyze) Header

func (r *Analyze) Header(key, value string) *Analyze

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

func (*Analyze) HttpRequest

func (r *Analyze) HttpRequest(ctx context.Context) (*http.Request, error)

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

func (*Analyze) Index

func (r *Analyze) Index(index string) *Analyze

Index Index used to derive the analyzer. If specified, the `analyzer` or field parameter overrides this value. If no index is specified or the index does not have a default analyzer, the analyze API uses the standard analyzer. API Name: index

func (*Analyze) Normalizer

func (r *Analyze) Normalizer(normalizer string) *Analyze

Normalizer Normalizer to use to convert text into a single token. API name: normalizer

func (Analyze) Perform

func (r Analyze) Perform(providedCtx context.Context) (*http.Response, error)

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

func (*Analyze) Raw

func (r *Analyze) Raw(raw io.Reader) *Analyze

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

func (*Analyze) Request

func (r *Analyze) Request(req *Request) *Analyze

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

func (*Analyze) Text

func (r *Analyze) Text(texttoanalyzes ...string) *Analyze

Text Text to analyze. If an array of strings is provided, it is analyzed as a multi-value field. API name: text

func (*Analyze) Tokenizer

func (r *Analyze) Tokenizer(tokenizer types.Tokenizer) *Analyze

Tokenizer Tokenizer to use to convert text into tokens. API name: tokenizer

type NewAnalyze

type NewAnalyze func() *Analyze

NewAnalyze type alias for index.

func NewAnalyzeFunc

func NewAnalyzeFunc(tp elastictransport.Interface) NewAnalyze

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

type Request

type Request struct {

	// Analyzer The name of the analyzer that should be applied to the provided `text`.
	// This could be a built-in analyzer, or an analyzer that’s been configured in
	// the index.
	Analyzer *string `json:"analyzer,omitempty"`
	// Attributes Array of token attributes used to filter the output of the `explain`
	// parameter.
	Attributes []string `json:"attributes,omitempty"`
	// CharFilter Array of character filters used to preprocess characters before the
	// tokenizer.
	CharFilter []types.CharFilter `json:"char_filter,omitempty"`
	// Explain If `true`, the response includes token attributes and additional details.
	Explain *bool `json:"explain,omitempty"`
	// Field Field used to derive the analyzer.
	// To use this parameter, you must specify an index.
	// If specified, the `analyzer` parameter overrides this value.
	Field *string `json:"field,omitempty"`
	// Filter Array of token filters used to apply after the tokenizer.
	Filter []types.TokenFilter `json:"filter,omitempty"`
	// Normalizer Normalizer to use to convert text into a single token.
	Normalizer *string `json:"normalizer,omitempty"`
	// Text Text to analyze.
	// If an array of strings is provided, it is analyzed as a multi-value field.
	Text []string `json:"text,omitempty"`
	// Tokenizer Tokenizer to use to convert text into tokens.
	Tokenizer types.Tokenizer `json:"tokenizer,omitempty"`
}

Request holds the request body struct for the package analyze

https://github.com/elastic/elasticsearch-specification/blob/5fb8f1ce9c4605abcaa44aa0f17dbfc60497a757/specification/indices/analyze/IndicesAnalyzeRequest.ts#L27-L92

func NewRequest

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON

func (r *Request) FromJSON(data string) (*Request, error)

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON

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

type Response

type Response struct {
	Detail *types.AnalyzeDetail `json:"detail,omitempty"`
	Tokens []types.AnalyzeToken `json:"tokens,omitempty"`
}

Response holds the response body struct for the package analyze

https://github.com/elastic/elasticsearch-specification/blob/5fb8f1ce9c4605abcaa44aa0f17dbfc60497a757/specification/indices/analyze/IndicesAnalyzeResponse.ts#L22-L27

func NewResponse

func NewResponse() *Response

NewResponse returns a Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL