Files
pages/internal/store/search.go
T
2026-11-15 05:47:14 +09:00

51 lines
2.2 KiB
Go

package store
import (
"context"
"pageswiki/internal/mestionora"
)
type SearchResult = mestionora.SearchResult
type PathSuggestion = mestionora.PathSuggestion
const (
SearchCandidateLimit = mestionora.SearchCandidateLimit
SearchExcerptDocumentBytes = mestionora.SearchExcerptDocumentBytes
SearchExcerptTotalBytes = mestionora.SearchExcerptTotalBytes
)
// SearchProfile is a capability, not a user preference. Clients must not
// mistake the initial native metadata search for a full-text index.
func (s *Store) SearchProfile() string {
if s.sqlBackend == storePostgreSQL {
return "metadata-only"
}
return "fulltext"
}
// SearchPathsInDomain is the legacy trusted-caller entry point. HTTP callers
// must pass their request policy to the filtered APIs; there is no implicit
// allow-all entry point in Mestionora itself.
func (s *Store) SearchPathsInDomain(domainUUID, scope, query string, limit int) ([]SearchResult, error) {
return s.SearchPathsInDomainFiltered(context.Background(), domainUUID, scope, query, limit, func(string) bool { return true })
}
func (s *Store) SearchPathsInDomainFiltered(ctx context.Context, domainUUID, scope, query string, limit int, allowed func(string) bool) ([]SearchResult, error) {
return s.SearchPathsInDomainWithOptions(ctx, domainUUID, scope, query, limit, allowed, SearchOptions{})
}
func (s *Store) SearchPathsInDomainWithOptions(ctx context.Context, domainUUID, scope, query string, limit int, allowed func(string) bool, options SearchOptions) ([]SearchResult, error) {
if s.sqlBackend == storePostgreSQL {
return mestionora.NewPostgreSQL(s.DB).SearchPathsInDomainWithOptions(ctx, domainUUID, scope, query, limit, allowed, options)
}
return mestionora.NewSQLite(s.DB).SearchPathsInDomainWithOptions(ctx, domainUUID, scope, query, limit, allowed, options)
}
func (s *Store) SearchPathSuggestionsInDomain(ctx context.Context, domainUUID, scope, query string, limit int, allowed func(string) bool) ([]PathSuggestion, error) {
if s.sqlBackend == storePostgreSQL {
return mestionora.NewPostgreSQL(s.DB).SearchPathSuggestionsInDomain(ctx, domainUUID, scope, query, limit, allowed)
}
return mestionora.NewSQLite(s.DB).SearchPathSuggestionsInDomain(ctx, domainUUID, scope, query, limit, allowed)
}