Documentation ¶
Overview ¶
Performs a kNN search.
Index ¶
- Variables
- type KnnSearch
- func (r KnnSearch) Do(providedCtx context.Context) (*Response, error)
- func (r *KnnSearch) DocvalueFields(docvaluefields ...types.FieldAndFormat) *KnnSearch
- func (r *KnnSearch) Fields(fields ...string) *KnnSearch
- func (r *KnnSearch) Filter(filters ...types.Query) *KnnSearch
- func (r *KnnSearch) Header(key, value string) *KnnSearch
- func (r *KnnSearch) HttpRequest(ctx context.Context) (*http.Request, error)
- func (r *KnnSearch) Knn(knn *types.CoreKnnQuery) *KnnSearch
- func (r KnnSearch) Perform(providedCtx context.Context) (*http.Response, error)
- func (r *KnnSearch) Raw(raw io.Reader) *KnnSearch
- func (r *KnnSearch) Request(req *Request) *KnnSearch
- func (r *KnnSearch) Routing(routing string) *KnnSearch
- func (r *KnnSearch) Source_(sourceconfig types.SourceConfig) *KnnSearch
- func (r *KnnSearch) StoredFields(fields ...string) *KnnSearch
- type NewKnnSearch
- type Request
- type Response
Constants ¶
This section is empty.
Variables ¶
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 New ¶
func New(tp elastictransport.Interface) *KnnSearch
Performs a kNN search.
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html
func (KnnSearch) Do ¶
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
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
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) HttpRequest ¶
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
Perform runs the http.Request through the provided transport and returns an http.Response.
func (*KnnSearch) Raw ¶
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 ¶
Request allows to set the request property with the appropriate payload.
func (*KnnSearch) Routing ¶
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
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 ¶
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
func (*Request) FromJSON ¶ added in v8.5.0
FromJSON allows to load an arbitrary json into the request structure
func (*Request) UnmarshalJSON ¶ added in v8.12.1
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