Help us shape the future of Go! Take the 2026 Go Developer Survey

search

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package search provides full-text search capabilities for knowledge graphs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IndexStats

type IndexStats struct {
	TotalDocs   uint64 `json:"total_docs"`
	IndexedAt   string `json:"indexed_at,omitempty"`
	IndexPath   string `json:"index_path,omitempty"`
	StorageSize int64  `json:"storage_size_bytes,omitempty"`
}

IndexStats provides statistics about the search index.

type IndexedNode

type IndexedNode struct {
	ID         string `json:"id"`
	Type       string `json:"type"`
	Label      string `json:"label"`
	Doc        string `json:"doc"`         // Docstring/description
	Package    string `json:"package"`     // Package name
	SourceFile string `json:"source_file"` // File path
	Module     string `json:"module"`      // Module name
	Signature  string `json:"signature"`   // Function/method signature
	AllText    string `json:"all_text"`    // Combined searchable text
}

IndexedNode is the document type stored in bleve.

type SearchOptions

type SearchOptions struct {
	Limit     int      // Maximum results to return (default 20)
	Offset    int      // Skip first N results
	NodeTypes []string // Filter by node types (function, class, etc.)
	FuzzyDist int      // Fuzzy matching edit distance (0=exact, 1-2=fuzzy)
	Highlight bool     // Include highlighted fragments
}

SearchOptions configures search behavior.

type SearchOutput

type SearchOutput struct {
	Query      string          `json:"query"`
	TotalHits  uint64          `json:"total_hits"`
	MaxScore   float64         `json:"max_score"`
	Results    []*SearchResult `json:"results"`
	Took       string          `json:"took"`
	Facets     map[string]any  `json:"facets,omitempty"`
	Truncated  bool            `json:"truncated,omitempty"`
	IndexStats *IndexStats     `json:"index_stats,omitempty"`
}

SearchOutput contains the full search response.

type SearchResult

type SearchResult struct {
	ID         string   `json:"id"`
	Score      float64  `json:"score"`
	Type       string   `json:"type"`
	Label      string   `json:"label,omitempty"`
	Package    string   `json:"package,omitempty"`
	SourceFile string   `json:"source_file,omitempty"`
	Snippet    string   `json:"snippet,omitempty"`
	Fragments  []string `json:"fragments,omitempty"`
}

SearchResult represents a single search hit.

type Searcher

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

Searcher provides full-text search over graph data.

func NewSearcher

func NewSearcher(graphPath string) (*Searcher, error)

NewSearcher creates a new searcher, opening or creating the index.

func (*Searcher) Close

func (s *Searcher) Close() error

Close closes the search index.

func (*Searcher) IndexNodes

func (s *Searcher) IndexNodes(nodes []*graph.Node) error

IndexNodes adds nodes to the search index.

func (*Searcher) Reindex

func (s *Searcher) Reindex(nodes []*graph.Node) error

Reindex clears and rebuilds the index from nodes.

func (*Searcher) Search

func (s *Searcher) Search(queryStr string, opts SearchOptions) (*SearchOutput, error)

Search performs a full-text search.

func (*Searcher) Stats

func (s *Searcher) Stats() (*IndexStats, error)

Stats returns index statistics.

Jump to

Keyboard shortcuts

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