traverser

package
v1.24.10 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCertaintyFromParams

func ExtractCertaintyFromParams(params dto.GetParams) (certainty float64)

func ExtractDistanceFromParams

func ExtractDistanceFromParams(params dto.GetParams) (distance float64, withDistance bool)

func MaxInt added in v1.20.4

func MaxInt(ints ...int) int

func MinInt added in v1.20.4

func MinInt(ints ...int) int

Types

type ExploreParams

type ExploreParams struct {
	NearVector        *searchparams.NearVector
	NearObject        *searchparams.NearObject
	Offset            int
	Limit             int
	ModuleParams      map[string]interface{}
	WithCertaintyProp bool
}

ExploreParams are the parameters used by the GraphQL `Explore { }` API

type Explorer

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

Explorer is a helper construct to perform vector-based searches. It does not contain monitoring or authorization checks. It should thus never be directly used by an API, but through a Traverser.

func NewExplorer

func NewExplorer(searcher objectsSearcher, logger logrus.FieldLogger, modulesProvider ModulesProvider, metrics explorerMetrics, conf config.Config) *Explorer

NewExplorer with search and connector repo

func (*Explorer) CalculateTotalLimit added in v1.20.4

func (e *Explorer) CalculateTotalLimit(pagination *filters.Pagination) (int, error)

func (*Explorer) CrossClassVectorSearch

func (e *Explorer) CrossClassVectorSearch(ctx context.Context,
	params ExploreParams,
) ([]search.Result, error)

func (*Explorer) GetClass

func (e *Explorer) GetClass(ctx context.Context,
	params dto.GetParams,
) ([]interface{}, error)

GetClass from search and connector repo

func (*Explorer) Hybrid

func (e *Explorer) Hybrid(ctx context.Context, params dto.GetParams) ([]search.Result, error)

func (*Explorer) SetSchemaGetter

func (e *Explorer) SetSchemaGetter(sg uc.SchemaGetter)

type Metrics

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

func NewMetrics

func NewMetrics(prom *monitoring.PrometheusMetrics) *Metrics

func (*Metrics) AddUsageDimensions

func (m *Metrics) AddUsageDimensions(className, queryType, operation string, dims int)

func (*Metrics) QueriesAggregateDec

func (m *Metrics) QueriesAggregateDec(className string)

func (*Metrics) QueriesAggregateInc

func (m *Metrics) QueriesAggregateInc(className string)

func (*Metrics) QueriesGetDec

func (m *Metrics) QueriesGetDec(className string)

func (*Metrics) QueriesGetInc

func (m *Metrics) QueriesGetInc(className string)

func (*Metrics) QueriesObserveDuration

func (m *Metrics) QueriesObserveDuration(className string, startMs int64)

type ModulesProvider

type ModulesProvider interface {
	ValidateSearchParam(name string, value interface{}, className string) error
	CrossClassValidateSearchParam(name string, value interface{}) error
	VectorFromSearchParam(ctx context.Context, className string, param string,
		params interface{}, findVectorFn modulecapabilities.FindVectorFn, tenant string) ([]float32, string, error)
	CrossClassVectorFromSearchParam(ctx context.Context, param string,
		params interface{}, findVectorFn modulecapabilities.FindVectorFn) ([]float32, string, error)
	GetExploreAdditionalExtend(ctx context.Context, in []search.Result,
		moduleParams map[string]interface{}, searchVector []float32,
		argumentModuleParams map[string]interface{}) ([]search.Result, error)
	ListExploreAdditionalExtend(ctx context.Context, in []search.Result,
		moduleParams map[string]interface{},
		argumentModuleParams map[string]interface{}) ([]search.Result, error)
	VectorFromInput(ctx context.Context, className, input, targetVector string) ([]float32, error)
}

type SearchParams

type SearchParams struct {
	// SearchType can be SearchTypeClass or SearchTypeProperty
	SearchType SearchType

	// Name is the string-representation of the class or property name
	Name string

	// Certainty must be a value between 0 and 1. The higher it is the narrower
	// is the search, the lower it is, the wider the search is
	Certainty float32
}

SearchParams to be used for a SchemaSearch. See individual properties for additional documentation on what they do

func (SearchParams) Validate

func (p SearchParams) Validate() error

Validate the feasibility of the specified arguments

type SearchResult

type SearchResult struct {
	Name      string
	Certainty float32
}

SearchResult is a single search result. See wrapping Search Results for the Type

type SearchResults

type SearchResults struct {
	Type    SearchType
	Results []SearchResult
}

SearchResults is grouping of SearchResults for a SchemaSearch

func (SearchResults) Len

func (r SearchResults) Len() int

Len of the result set

type SearchType

type SearchType string

SearchType to search for either class names or property names

const (
	// SearchTypeClass to search the contextionary for class names
	SearchTypeClass SearchType = "class"
	// SearchTypeProperty to search the contextionary for property names
	SearchTypeProperty SearchType = "property"
)

type TargetVectorParamHelper added in v1.24.5

type TargetVectorParamHelper struct{}

func NewTargetParamHelper added in v1.24.5

func NewTargetParamHelper() *TargetVectorParamHelper

func (*TargetVectorParamHelper) GetTargetVectorFromParams added in v1.24.5

func (t *TargetVectorParamHelper) GetTargetVectorFromParams(params dto.GetParams) string

func (*TargetVectorParamHelper) GetTargetVectorOrDefault added in v1.24.5

func (t *TargetVectorParamHelper) GetTargetVectorOrDefault(sch schema.Schema, className, targetVector string) (string, error)

type Traverser

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

Traverser can be used to dynamically traverse the knowledge graph

func NewTraverser

func NewTraverser(config *config.WeaviateConfig, locks locks,
	logger logrus.FieldLogger, authorizer authorizer,
	vectorSearcher VectorSearcher,
	explorer explorer, schemaGetter schema.SchemaGetter,
	modulesProvider ModulesProvider,
	metrics *Metrics, maxGetRequests int,
) *Traverser

NewTraverser to traverse the knowledge graph

func (*Traverser) Aggregate

func (t *Traverser) Aggregate(ctx context.Context, principal *models.Principal,
	params *aggregation.Params,
) (interface{}, error)

Aggregate resolves meta queries

func (*Traverser) Explore

func (t *Traverser) Explore(ctx context.Context,
	principal *models.Principal, params ExploreParams,
) ([]search.Result, error)

Explore through unstructured search terms

func (*Traverser) GetClass

func (t *Traverser) GetClass(ctx context.Context, principal *models.Principal,
	params dto.GetParams,
) ([]interface{}, error)

type TraverserRepo

type TraverserRepo interface {
	GetClass(context.Context, *dto.GetParams) (interface{}, error)
	Aggregate(context.Context, *aggregation.Params) (interface{}, error)
}

TraverserRepo describes the dependencies of the Traverser UC to the connected database

type VectorSearcher

type VectorSearcher interface {
	Aggregate(ctx context.Context, params aggregation.Params) (*aggregation.Result, error)
	Object(ctx context.Context, className string, id strfmt.UUID,
		props search.SelectProperties, additional additional.Properties,
		properties *additional.ReplicationProperties, tenant string) (*search.Result, error)
	ObjectsByID(ctx context.Context, id strfmt.UUID, props search.SelectProperties,
		additional additional.Properties, tenant string) (search.Results, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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