traverser

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCertaintyFromParams

func ExtractCertaintyFromParams(params GetParams) (certainty float64)

func ExtractDistanceFromParams

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

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(search vectorClassSearch, logger logrus.FieldLogger,
	modulesProvider ModulesProvider, metrics explorerMetrics,
) *Explorer

NewExplorer with search and connector repo

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 GetParams,
) ([]interface{}, error)

GetClass from search and connector repo

func (*Explorer) Hybrid

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

func (*Explorer) SetSchemaGetter

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

type GetParams

type GetParams struct {
	Filters              *filters.LocalFilter
	ClassName            string
	Pagination           *filters.Pagination
	Sort                 []filters.Sort
	Properties           search.SelectProperties
	NearVector           *searchparams.NearVector
	NearObject           *searchparams.NearObject
	KeywordRanking       *searchparams.KeywordRanking
	HybridSearch         *searchparams.HybridSearch
	SearchVector         []float32
	Group                *GroupParams
	ModuleParams         map[string]interface{}
	AdditionalProperties additional.Properties
}

type GroupParams

type GroupParams struct {
	Strategy string
	Force    float32
}

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) ([]float32, error)
	CrossClassVectorFromSearchParam(ctx context.Context, param string,
		params interface{}, findVectorFn modulecapabilities.FindVectorFn) ([]float32, 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 string, input 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

	// Certaintiy 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 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 GetParams,
) (interface{}, error)

type TraverserRepo

type TraverserRepo interface {
	GetClass(context.Context, *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 {
	VectorSearch(ctx context.Context, vector []float32,
		offset, limit int, filters *filters.LocalFilter) ([]search.Result, error)
	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) (*search.Result, error)
	ObjectsByID(ctx context.Context, id strfmt.UUID,
		props search.SelectProperties, additional additional.Properties) (search.Results, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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