knnsearch

package
v8.13.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Overview

Performs a kNN search.

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 KnnSearch

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

func (KnnSearch) Do

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

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

func (*KnnSearch) DocvalueFields added in v8.9.0

func (r *KnnSearch) DocvalueFields(docvaluefields ...types.FieldAndFormat) *KnnSearch

DocvalueFields The request returns doc values for field names matching these patterns in the hits.fields property of the response. Accepts wildcard (*) patterns. API name: docvalue_fields

func (*KnnSearch) Fields added in v8.9.0

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

Fields The request returns values for field names matching these patterns in the hits.fields property of the response. Accepts wildcard (*) patterns. API name: fields

func (*KnnSearch) Filter added in v8.9.0

func (r *KnnSearch) Filter(filters ...types.Query) *KnnSearch

Filter Query to filter the documents that can match. The kNN search will return the top `k` documents that also match this filter. The value can be a single query or a list of queries. If `filter` isn't provided, all documents are allowed to match. API name: filter

func (*KnnSearch) Header

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

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

func (*KnnSearch) HttpRequest

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

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

func (*KnnSearch) Knn added in v8.9.0

func (r *KnnSearch) Knn(knn *types.CoreKnnQuery) *KnnSearch

Knn kNN query to execute API name: knn

func (KnnSearch) Perform added in v8.7.0

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

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

func (*KnnSearch) Raw

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

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

func (*KnnSearch) Request

func (r *KnnSearch) Request(req *Request) *KnnSearch

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

func (*KnnSearch) Routing

func (r *KnnSearch) Routing(routing string) *KnnSearch

Routing A comma-separated list of specific routing values API name: routing

func (*KnnSearch) Source_ added in v8.9.0

func (r *KnnSearch) Source_(sourceconfig types.SourceConfig) *KnnSearch

Source_ Indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response. API name: _source

func (*KnnSearch) StoredFields added in v8.9.0

func (r *KnnSearch) StoredFields(fields ...string) *KnnSearch

StoredFields List of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the _source parameter defaults to false. You can pass _source: true to return both source fields and stored fields in the search response. API name: stored_fields

type NewKnnSearch

type NewKnnSearch func(index string) *KnnSearch

NewKnnSearch type alias for index.

func NewKnnSearchFunc

func NewKnnSearchFunc(tp elastictransport.Interface) NewKnnSearch

NewKnnSearchFunc returns a new instance of KnnSearch 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 {

	// DocvalueFields The request returns doc values for field names matching these patterns
	// in the hits.fields property of the response. Accepts wildcard (*) patterns.
	DocvalueFields []types.FieldAndFormat `json:"docvalue_fields,omitempty"`
	// Fields The request returns values for field names matching these patterns
	// in the hits.fields property of the response. Accepts wildcard (*) patterns.
	Fields []string `json:"fields,omitempty"`
	// Filter Query to filter the documents that can match. The kNN search will return the
	// top
	// `k` documents that also match this filter. The value can be a single query or
	// a
	// list of queries. If `filter` isn't provided, all documents are allowed to
	// match.
	Filter []types.Query `json:"filter,omitempty"`
	// Knn kNN query to execute
	Knn types.CoreKnnQuery `json:"knn"`
	// Source_ Indicates which source fields are returned for matching documents. These
	// fields are returned in the hits._source property of the search response.
	Source_ types.SourceConfig `json:"_source,omitempty"`
	// StoredFields List of stored fields to return as part of a hit. If no fields are specified,
	// no stored fields are included in the response. If this field is specified,
	// the _source
	// parameter defaults to false. You can pass _source: true to return both source
	// fields
	// and stored fields in the search response.
	StoredFields []string `json:"stored_fields,omitempty"`
}

Request holds the request body struct for the package knnsearch

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/_global/knn_search/KnnSearchRequest.ts#L27-L80

func NewRequest added in v8.5.0

func NewRequest() *Request

NewRequest returns a Request

func (*Request) FromJSON added in v8.5.0

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

FromJSON allows to load an arbitrary json into the request structure

func (*Request) UnmarshalJSON added in v8.12.1

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

type Response added in v8.7.0

type Response struct {

	// Fields Contains field values for the documents. These fields
	// must be specified in the request using the `fields` parameter.
	Fields map[string]json.RawMessage `json:"fields,omitempty"`
	// Hits Contains returned documents and metadata.
	Hits types.HitsMetadata `json:"hits"`
	// MaxScore Highest returned document score. This value is null for requests
	// that do not sort by score.
	MaxScore *types.Float64 `json:"max_score,omitempty"`
	// Shards_ Contains a count of shards used for the request.
	Shards_ types.ShardStatistics `json:"_shards"`
	// TimedOut If true, the request timed out before completion;
	// returned results may be partial or empty.
	TimedOut bool `json:"timed_out"`
	// Took Milliseconds it took Elasticsearch to execute the request.
	Took int64 `json:"took"`
}

Response holds the response body struct for the package knnsearch

https://github.com/elastic/elasticsearch-specification/blob/5bf86339cd4bda77d07f6eaa6789b72f9c0279b1/specification/_global/knn_search/KnnSearchResponse.ts#L26-L54

func NewResponse added in v8.7.0

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