docindex

package
v0.36.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocSummary

type DocSummary struct {
	DocPath   string       `json:"docPath"`
	PageCount int          `json:"pageCount"`
	Pages     []*PageEntry `json:"pages,omitempty"`
	IndexedAt int64        `json:"indexedAt"`
}

DocSummary holds a document's metadata for the UI listing. Pages is only populated by callers that explicitly attach full page data; the docs listing leaves it empty to keep the payload small.

type ExcludeEntry added in v0.7.0

type ExcludeEntry struct {
	ID        string `json:"id"`
	Directory string `json:"directory"`
	Pattern   string `json:"pattern"`
	CreatedAt int64  `json:"createdAt"`
}

ExcludeEntry is a pattern that the indexer skips during a walk. Patterns are matched against directory names and file basenames. Glob wildcards (e.g. *.min.js) are supported via filepath.Match.

type PageEntry

type PageEntry struct {
	ID        string   `json:"id"`
	DocPath   string   `json:"docPath"`
	PageNum   int      `json:"pageNum"`
	Keywords  []string `json:"keywords"`
	Labels    []string `json:"labels"`
	IndexedAt int64    `json:"indexedAt"`
}

PageEntry represents a single indexed page in a PDF document.

type Store

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

Store provides persistence for doc_page_index entries.

func NewStore

func NewStore(database *db.DB) *Store

NewStore creates a new Store backed by the given database.

func (*Store) AddExclude added in v0.7.0

func (s *Store) AddExclude(dir, pattern string) (*ExcludeEntry, error)

AddExclude inserts a new exclude pattern for a directory. Duplicate patterns are ignored.

func (*Store) DeleteAllByPrefix

func (s *Store) DeleteAllByPrefix(dirPrefix string) error

DeleteAllByPrefix deletes all entries for docs under dirPrefix (directory boundary semantics, see dirPrefixFilter).

func (*Store) DeleteByDoc

func (s *Store) DeleteByDoc(docPath string) error

DeleteByDoc removes all PageEntry rows for a given document path.

func (*Store) DeleteExclude added in v0.7.0

func (s *Store) DeleteExclude(excludeID string) error

DeleteExclude removes an exclude entry by ID.

func (*Store) GetByDoc

func (s *Store) GetByDoc(docPath string) ([]*PageEntry, error)

GetByDoc returns all PageEntry rows for a given document path.

func (*Store) IsDocIndexed added in v0.7.0

func (s *Store) IsDocIndexed(docPath string) (bool, error)

IsDocIndexed reports whether any pages for the given document path exist in the index.

func (*Store) ListDocPaths added in v0.19.3

func (s *Store) ListDocPaths(dirPrefix string) ([]string, error)

ListDocPaths returns the distinct doc_path values under dirPrefix (directory boundary semantics, see dirPrefixFilter). It is used by the indexer to detect stale entries for files that no longer exist on disk.

func (*Store) ListDocsSummary

func (s *Store) ListDocsSummary(dirPrefix string) ([]*DocSummary, error)

ListDocsSummary returns one DocSummary per unique doc_path whose path is under dirPrefix. It aggregates in a single query and does not load per-page label data — callers that need full pages should use GetByDoc.

func (*Store) ListDocxFiles added in v0.13.6

func (s *Store) ListDocxFiles(dirPrefix string) ([]*PageEntry, error)

ListDocxFiles returns all indexed DOCX entries (page-level) whose doc_path is under dirPrefix (directory-boundary semantics, see dirPrefixFilter), ordered by path then page number. Each DOCX document will have one entry per pseudo-page; callers group them by DocPath.

func (*Store) ListExcludes added in v0.7.0

func (s *Store) ListExcludes(dir string) ([]*ExcludeEntry, error)

ListExcludes returns all exclude patterns stored for the given directory.

func (*Store) ListPDFFiles added in v0.13.6

func (s *Store) ListPDFFiles(dirPrefix string) ([]*PageEntry, error)

ListPDFFiles returns all indexed PDF entries (page-level) whose doc_path is under dirPrefix (directory-boundary semantics, see dirPrefixFilter), ordered by path then page number. Each PDF document will have one entry per page; callers group them by DocPath.

func (*Store) ListTextFiles added in v0.7.0

func (s *Store) ListTextFiles(dirPrefix string) ([]*PageEntry, error)

ListTextFiles returns all indexed non-PDF, non-DOCX entries whose doc_path is under dirPrefix (the boundary is the directory separator, so a sibling folder sharing the prefix never matches), ordered by path. Each text/code file has exactly one entry (page 1).

func (*Store) SeedDefaultExcludes added in v0.7.0

func (s *Store) SeedDefaultExcludes(dir string) error

SeedDefaultExcludes inserts the default patterns for a directory if none exist yet.

func (*Store) UpdateLabels

func (s *Store) UpdateLabels(docPath string, pageNum int, labels []string) error

UpdateLabels updates only the labels field for a specific page.

func (*Store) Upsert

func (s *Store) Upsert(entry *PageEntry) error

Upsert inserts or replaces a PageEntry in the database.

Jump to

Keyboard shortcuts

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