index

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package index provides full-text search indexing for project descriptions using Bleve

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanMarkdown

func CleanMarkdown(md string) string

CleanMarkdown removes Markdown formatting and extracts plain text Preserves headings, paragraphs, and lists but removes code blocks, links syntax, etc.

func Exists

func Exists(indexPath string) bool

Exists checks if the index exists at the given path

Types

type CombinedMatch

type CombinedMatch struct {
	Project      types.Project
	Snippet      string      // Description snippet if found there
	SearchScore  float64     // Bleve relevance score
	TotalScore   float64     // Combined score (SearchScore + HistoryScore)
	HistoryScore int         // History boost (with exponential decay)
	Source       MatchSource // Bitflags: can be MatchSourceName | MatchSourceDescription
}

CombinedMatch represents a unified search result with score breakdown

type DescriptionDocument

type DescriptionDocument struct {
	ProjectPath string // e.g., "numbuster/api/auth"
	ProjectName string // e.g., "line-login-initiator"
	Description string // Project description
}

DescriptionDocument represents an indexed project description

type DescriptionIndex

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

DescriptionIndex manages the bleve index for project descriptions

func NewDescriptionIndex

func NewDescriptionIndex(indexPath string) (*DescriptionIndex, error)

NewDescriptionIndex creates or opens a description index

func (*DescriptionIndex) Add

func (di *DescriptionIndex) Add(projectPath, projectName, description string) error

Add indexes a description document

func (*DescriptionIndex) AddBatch

func (di *DescriptionIndex) AddBatch(docs []DescriptionDocument) error

AddBatch indexes multiple description documents in a batch

func (*DescriptionIndex) Close

func (di *DescriptionIndex) Close() error

Close closes the index

func (*DescriptionIndex) Count

func (di *DescriptionIndex) Count() (uint64, error)

Count returns the number of indexed documents

func (*DescriptionIndex) Delete

func (di *DescriptionIndex) Delete(projectPath string) error

Delete removes a document from the index

func (*DescriptionIndex) GetAllProjects

func (di *DescriptionIndex) GetAllProjects() ([]types.Project, error)

GetAllProjects retrieves all projects from the index Returns all indexed projects (no pagination)

func (*DescriptionIndex) Search

func (di *DescriptionIndex) Search(query string, maxResults int) ([]DescriptionMatch, error)

Search performs a full-text search across ProjectName, ProjectPath, and Description Uses field boosting: ProjectName (5x), ProjectPath (2x), Description (1x) Supports multi-word queries with AND logic (all words must be present)

type DescriptionMatch

type DescriptionMatch struct {
	Project types.Project // The matched project
	Snippet string        // Context snippet with highlighted match
	Score   float64       // Relevance score from bleve
}

DescriptionMatch represents a search result from description index

type MatchSource

type MatchSource int

MatchSource indicates where the match was found

const (
	// MatchSourceName indicates match found in project name (fuzzy)
	MatchSourceName MatchSource = 1 << iota
	// MatchSourceDescription indicates match found in description (bleve)
	MatchSourceDescription
)

Jump to

Keyboard shortcuts

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