search

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSearchTimeout prevents runaway queries from exhausting connections
	DefaultSearchTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FacetValue added in v0.4.1

type FacetValue struct {
	Value string `json:"value"`
	Count int    `json:"count"`
}

type Facets added in v0.4.1

type Facets struct {
	Types      map[ResultType]int `json:"types"`
	AssetTypes []FacetValue       `json:"asset_types"`
	Providers  []FacetValue       `json:"providers"`
	Tags       []FacetValue       `json:"tags"`
}

type Filter

type Filter struct {
	Query      string       `json:"query" validate:"omitempty,max=256"` // Optional query for full-text search
	Types      []ResultType `json:"types,omitempty"`
	AssetTypes []string     `json:"asset_types,omitempty"` // Filter assets by type (TABLE, VIEW, etc.)
	Providers  []string     `json:"providers,omitempty"`   // Filter assets by provider
	Tags       []string     `json:"tags,omitempty"`        // Filter assets by tags
	Limit      int          `json:"limit" validate:"omitempty,gte=1,lte=100"`
	Offset     int          `json:"offset" validate:"omitempty,gte=0"`
}

Filter represents search filter options

type PostgresRepository

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

func NewPostgresRepository

func NewPostgresRepository(db *pgxpool.Pool, recorder metrics.Recorder) *PostgresRepository

func (*PostgresRepository) GetMetadata added in v0.6.0

func (r *PostgresRepository) GetMetadata(ctx context.Context, resultType ResultType, ids []string) (map[string]map[string]interface{}, error)

GetMetadata fetches full metadata for a set of results by type and IDs. This is used for lazy loading detailed information after initial search.

func (*PostgresRepository) Search

func (r *PostgresRepository) Search(ctx context.Context, filter Filter) ([]*Result, int, *Facets, error)

Search performs a unified search across all entity types using the search_index table. It routes queries to optimized paths based on query characteristics.

type Repository

type Repository interface {
	Search(ctx context.Context, filter Filter) ([]*Result, int, *Facets, error)
	GetMetadata(ctx context.Context, resultType ResultType, ids []string) (map[string]map[string]interface{}, error)
}

type Response

type Response struct {
	Results []*Result `json:"results"`
	Total   int       `json:"total"`
	Facets  *Facets   `json:"facets"`
	Limit   int       `json:"limit"`
	Offset  int       `json:"offset"`
}

type Result

type Result struct {
	Type        ResultType             `json:"type"`
	ID          string                 `json:"id"`
	Name        string                 `json:"name"`
	Description *string                `json:"description,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
	URL         string                 `json:"url"`
	Rank        float32                `json:"rank"`
	UpdatedAt   *time.Time             `json:"updated_at,omitempty"`
}

Result represents a unified search result

type ResultType

type ResultType string

ResultType represents the type of search result

const (
	ResultTypeAsset       ResultType = "asset"
	ResultTypeGlossary    ResultType = "glossary"
	ResultTypeTeam        ResultType = "team"
	ResultTypeDataProduct ResultType = "data_product"
)

type Service

type Service interface {
	Search(ctx context.Context, filter Filter) (*Response, error)
}

func NewService

func NewService(repo Repository) Service

Jump to

Keyboard shortcuts

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