vectorstore

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package vectorstore adapts core vector search to the rag Retriever contract. Search policy is fixed at construction; parsed per-query filters belong to this adapter and travel through rag's typed query values.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterValueKey

func FilterValueKey() rag.ValueKey[filter.Predicate]

FilterValueKey returns the typed query slot for a parsed per-call filter. Parse textual filter DSL with filter.Parse before attaching it.

Example
package main

import (
	"fmt"

	"github.com/Tangerg/scope/core/vectorstore/filter"
	"github.com/Tangerg/scope/rag"

	ragvectorstore "github.com/Tangerg/scope/rag/vectorstore"
)

func main() {
	predicate, err := filter.Parse(`tenant == 'acme'`)
	if err != nil {
		panic(err)
	}
	query, err := rag.NewQuery("release notes")
	if err != nil {
		panic(err)
	}
	query, err = query.WithValue(ragvectorstore.FilterValueKey(), predicate)
	if err != nil {
		panic(err)
	}
	_, found, err := query.Value(ragvectorstore.FilterValueKey())
	if err != nil {
		panic(err)
	}
	fmt.Println(query.Text(), found)
}
Output:
release notes true

Types

type Retriever

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

Retriever retrieves candidates from a core vector store.

func NewRetriever

func NewRetriever(config RetrieverConfig) (*Retriever, error)

NewRetriever validates the search boundary and its defaults.

func (*Retriever) Retrieve

func (r *Retriever) Retrieve(ctx context.Context, query rag.Query) (rag.Candidates, error)

Retrieve issues the configured relevance search via the underlying vector store.

type RetrieverConfig

type RetrieverConfig struct {
	// VectorStore performs the actual relevance search. Required.
	VectorStore corevs.Searcher

	// TopK caps the number of returned documents. Zero uses
	// [corevs.DefaultTopK]; negative values are invalid.
	TopK int

	// MinScore filters semantic matches below this relevance threshold. Hybrid
	// mode requires zero because fusion scores are not portable across stores.
	// Range [0.0, 1.0].
	MinScore corevs.Score

	// SearchMode selects semantic or native hybrid retrieval. The zero value is
	// semantic; a store that cannot honor hybrid returns a typed error.
	SearchMode corevs.SearchMode

	// FilterFunc dynamically builds a metadata filter from the complete query.
	// Optional; when [FilterValueKey] is set, the per-query filter wins.
	FilterFunc func(ctx context.Context, query rag.Query) (filter.Predicate, error)
}

RetrieverConfig binds one search capability and its defaults. Per-query filters remain on Query.

Jump to

Keyboard shortcuts

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