index

package
v0.0.0-...-e803270 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	ID      string
	Path    string
	Content string
	ModTime int64
	Size    int64
}

Document represents an indexed document

type InvertedIndex

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

InvertedIndex stores the inverted index structure

func NewInvertedIndex

func NewInvertedIndex() *InvertedIndex

NewInvertedIndex creates a new inverted index

func (*InvertedIndex) AddDocument

func (idx *InvertedIndex) AddDocument(doc *Document, tokens []string, positions []int)

AddDocument adds or updates a document in the index

func (*InvertedIndex) Deserialize

func (idx *InvertedIndex) Deserialize(data []byte) error

Deserialize decodes the index from storage

func (*InvertedIndex) FuzzySearch

func (idx *InvertedIndex) FuzzySearch(queryTerms []string, maxDistance int) []SearchResult

FuzzySearch performs fuzzy matching search

func (*InvertedIndex) GetDocument

func (idx *InvertedIndex) GetDocument(docID string) (*Document, bool)

GetDocument retrieves a document by ID

func (*InvertedIndex) GetStats

func (idx *InvertedIndex) GetStats() Stats

GetStats returns index statistics

func (*InvertedIndex) RemoveDocument

func (idx *InvertedIndex) RemoveDocument(docID string)

RemoveDocument removes a document from the index

func (*InvertedIndex) Search

func (idx *InvertedIndex) Search(queryTerms []string) []SearchResult

Search performs a search query and returns ranked results

func (*InvertedIndex) Serialize

func (idx *InvertedIndex) Serialize() ([]byte, error)

Serialize encodes the index for storage

type Posting

type Posting struct {
	DocID     string
	Frequency int
	Positions []int
}

Posting represents a document that contains a term

type SearchResult

type SearchResult struct {
	Document   *Document
	Score      float64
	MatchCount int
	QueryTerms int
}

SearchResult represents a search result with scoring

type Stats

type Stats struct {
	DocumentCount int
	TermCount     int
}

Stats contains index statistics

Jump to

Keyboard shortcuts

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