Documentation
¶
Index ¶
- Constants
- Variables
- type ExternalSearchService
- type FacetValue
- type Facets
- type Filter
- type IndexRepository
- type IndexSyncService
- func (s *IndexSyncService) DeleteAsset(ctx context.Context, assetID string)
- func (s *IndexSyncService) OnEntityChanged(ctx context.Context, entityType, entityID string)
- func (s *IndexSyncService) OnEntityDeleted(ctx context.Context, entityType, entityID string)
- func (s *IndexSyncService) Start(ctx context.Context)
- func (s *IndexSyncService) Stop()
- func (s *IndexSyncService) SyncAsset(ctx context.Context, assetID string)
- type NoopReindexBroadcaster
- func (n *NoopReindexBroadcaster) BroadcastCompleted(indexed, errors, total int)
- func (n *NoopReindexBroadcaster) BroadcastFailed(err error, indexed, errors, total int)
- func (n *NoopReindexBroadcaster) BroadcastProgress(indexed, errors, total int)
- func (n *NoopReindexBroadcaster) BroadcastStarted(total int)
- type PostgresRepository
- func (r *PostgresRepository) CountSearchDocuments(ctx context.Context) (int, error)
- func (r *PostgresRepository) GetMetadata(ctx context.Context, resultType ResultType, ids []string) (map[string]map[string]interface{}, error)
- func (r *PostgresRepository) GetSearchDocument(ctx context.Context, entityType, entityID string) (*SearchDocument, error)
- func (r *PostgresRepository) ScanSearchDocuments(ctx context.Context, afterType, afterID string, limit int) ([]SearchDocument, error)
- func (r *PostgresRepository) Search(ctx context.Context, filter Filter) ([]*Result, int, *Facets, error)
- type ReindexBroadcaster
- type Reindexer
- type Repository
- type Response
- type Result
- type ResultType
- type SearchDocument
- type SearchIndexer
- type SearchObserver
- type Service
Constants ¶
const ( // DefaultSearchTimeout prevents runaway queries from exhausting connections DefaultSearchTimeout = 10 * time.Second )
Variables ¶
var ErrReindexInProgress = errors.New("reindex already in progress")
Functions ¶
This section is empty.
Types ¶
type ExternalSearchService ¶ added in v0.8.0
type ExternalSearchService struct {
// contains filtered or unexported fields
}
ExternalSearchService routes text queries to an external search indexer and browse/empty queries to the PostgreSQL-backed service.
type FacetValue ¶ added in v0.4.1
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 IndexRepository ¶ added in v0.8.0
type IndexRepository interface {
GetSearchDocument(ctx context.Context, entityType, entityID string) (*SearchDocument, error)
ScanSearchDocuments(ctx context.Context, afterType, afterID string, limit int) ([]SearchDocument, error)
CountSearchDocuments(ctx context.Context) (int, error)
}
IndexRepository provides read access to the search_index table for syncing.
type IndexSyncService ¶ added in v0.8.0
type IndexSyncService struct {
// contains filtered or unexported fields
}
IndexSyncService keeps an external search index in sync with the search_index table. It implements SearchObserver for all entity types and is wired as an asset observer adapter in server.go.
func NewIndexSyncService ¶ added in v0.8.0
func NewIndexSyncService(indexer SearchIndexer, repo IndexRepository) *IndexSyncService
NewIndexSyncService creates a new sync service.
func (*IndexSyncService) DeleteAsset ¶ added in v0.8.0
func (s *IndexSyncService) DeleteAsset(ctx context.Context, assetID string)
DeleteAsset deletes an asset from the index. Called by the adapter in server.go.
func (*IndexSyncService) OnEntityChanged ¶ added in v0.8.0
func (s *IndexSyncService) OnEntityChanged(ctx context.Context, entityType, entityID string)
OnEntityChanged implements SearchObserver. It reads the entity from the search_index table and pushes it to the external index.
func (*IndexSyncService) OnEntityDeleted ¶ added in v0.8.0
func (s *IndexSyncService) OnEntityDeleted(ctx context.Context, entityType, entityID string)
OnEntityDeleted implements SearchObserver. It removes the entity from the external index.
func (*IndexSyncService) Start ¶ added in v0.8.0
func (s *IndexSyncService) Start(ctx context.Context)
Start begins processing sync events.
func (*IndexSyncService) Stop ¶ added in v0.8.0
func (s *IndexSyncService) Stop()
Stop stops processing sync events and waits for in-flight operations.
type NoopReindexBroadcaster ¶ added in v0.8.0
type NoopReindexBroadcaster struct{}
NoopReindexBroadcaster is a broadcaster that does nothing (for when websockets are disabled).
func (*NoopReindexBroadcaster) BroadcastCompleted ¶ added in v0.8.0
func (n *NoopReindexBroadcaster) BroadcastCompleted(indexed, errors, total int)
func (*NoopReindexBroadcaster) BroadcastFailed ¶ added in v0.8.0
func (n *NoopReindexBroadcaster) BroadcastFailed(err error, indexed, errors, total int)
func (*NoopReindexBroadcaster) BroadcastProgress ¶ added in v0.8.0
func (n *NoopReindexBroadcaster) BroadcastProgress(indexed, errors, total int)
func (*NoopReindexBroadcaster) BroadcastStarted ¶ added in v0.8.0
func (n *NoopReindexBroadcaster) BroadcastStarted(total int)
type PostgresRepository ¶
type PostgresRepository struct {
// contains filtered or unexported fields
}
func NewPostgresRepository ¶
func NewPostgresRepository(db *pgxpool.Pool, recorder metrics.Recorder) *PostgresRepository
func (*PostgresRepository) CountSearchDocuments ¶ added in v0.8.0
func (r *PostgresRepository) CountSearchDocuments(ctx context.Context) (int, error)
CountSearchDocuments returns the total number of rows in search_index.
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) GetSearchDocument ¶ added in v0.8.0
func (r *PostgresRepository) GetSearchDocument(ctx context.Context, entityType, entityID string) (*SearchDocument, error)
GetSearchDocument reads a single row from the search_index table.
func (*PostgresRepository) ScanSearchDocuments ¶ added in v0.8.0
func (r *PostgresRepository) ScanSearchDocuments(ctx context.Context, afterType, afterID string, limit int) ([]SearchDocument, error)
ScanSearchDocuments reads search_index rows using keyset pagination. Pass empty strings for afterType/afterID to start from the beginning.
type ReindexBroadcaster ¶ added in v0.8.0
type ReindexBroadcaster interface {
BroadcastStarted(total int)
BroadcastProgress(indexed, errors, total int)
BroadcastCompleted(indexed, errors, total int)
BroadcastFailed(err error, indexed, errors, total int)
}
ReindexBroadcaster defines the interface for broadcasting reindex progress events.
type Reindexer ¶ added in v0.8.0
type Reindexer struct {
// contains filtered or unexported fields
}
Reindexer reads from the search_index table and bulk-indexes to the external search backend.
func NewReindexer ¶ added in v0.8.0
func NewReindexer(indexer SearchIndexer, repo IndexRepository, batchSize int) *Reindexer
NewReindexer creates a new reindexer.
func (*Reindexer) RunOnce ¶ added in v0.8.0
RunOnce performs a full reindex from the search_index table to the external search backend. It is idempotent and can be called concurrently (subsequent calls are rejected if one is already running).
func (*Reindexer) SetBroadcaster ¶ added in v0.8.0
func (r *Reindexer) SetBroadcaster(b ReindexBroadcaster)
SetBroadcaster sets the broadcaster for reindex progress events.
type Repository ¶
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 SearchDocument ¶ added in v0.8.0
type SearchDocument struct {
Type string
EntityID string
Name string
Description *string
URLPath string
AssetType *string
PrimaryProvider *string
Providers []string
Tags []string
MRN *string
CreatedBy *string
CreatedAt *time.Time
UpdatedAt time.Time
Metadata map[string]interface{}
Documentation *string
}
SearchDocument mirrors search_index table rows for external indexing.
type SearchIndexer ¶ added in v0.8.0
type SearchIndexer interface {
Index(ctx context.Context, doc SearchDocument) error
BulkIndex(ctx context.Context, docs []SearchDocument) error
Delete(ctx context.Context, entityType, entityID string) error
Search(ctx context.Context, filter Filter) ([]*Result, int, *Facets, error)
Healthy(ctx context.Context) bool
CreateIndex(ctx context.Context) error
Close() error
}
SearchIndexer defines the interface for external search backends.
type SearchObserver ¶ added in v0.8.0
type SearchObserver interface {
OnEntityChanged(ctx context.Context, entityType, entityID string)
OnEntityDeleted(ctx context.Context, entityType, entityID string)
}
SearchObserver is notified when non-asset entities change.
type Service ¶
func NewExternalSearchService ¶ added in v0.8.0
func NewExternalSearchService(indexer SearchIndexer, pgSvc Service, timeout time.Duration) Service
NewExternalSearchService creates a new service that routes queries between an external indexer and the existing PG search service.
func NewService ¶
func NewService(repo Repository) Service