search

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package search provides FTS5-based full-text search business logic for Cortex.

This package implements the search domain service, which provides a clean API layer on top of the SearchRepository. It handles query sanitization, option validation, and result formatting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service provides business logic for full-text search operations. It wraps a SearchRepository to provide a clean API with query sanitization and result validation.

func NewService

func NewService(repo domain.SearchRepository) *Service

NewService creates a new search service with the given repository.

func (*Service) Search

func (s *Service) Search(ctx context.Context, query string, opts domain.SearchOptions) ([]*domain.SearchResult, error)

Search performs a full-text search with the given query and options. The query is sanitized for FTS5 before being passed to the repository.

The method validates options and applies defaults:

  • If limit is 0 or negative, defaults to 10
  • If limit exceeds 100, it's capped at 100

Returns search results ordered by relevance (rank).

func (*Service) SearchObservations

func (s *Service) SearchObservations(ctx context.Context, query string, project string, limit int) ([]*domain.SearchResult, error)

SearchObservations searches only observations with the given filters. This is a convenience method that sets appropriate filters in SearchOptions.

Parameters:

  • query: the search query (will be sanitized for FTS5)
  • project: optional project filter (empty string means no filter)
  • limit: maximum number of results (defaults to 10 if <= 0)

Returns observations matching the query, ordered by relevance.

func (*Service) SearchPrompts

func (s *Service) SearchPrompts(ctx context.Context, query string, project string, limit int) ([]*domain.SearchResult, error)

SearchPrompts searches only user prompts with the given filters. This method is provided for future extensibility when prompts are indexed separately in FTS5.

Parameters:

  • query: the search query (will be sanitized for FTS5)
  • project: optional project filter (empty string means no filter)
  • limit: maximum number of results (defaults to 10 if <= 0)

Returns prompts matching the query, ordered by relevance.

Jump to

Keyboard shortcuts

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