indexing

package
v0.0.0-...-504b4e1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() *all

func And

func And(clauses ...Query) *and

func None

func None() *none

func Not

func Not(clause Query) *not

func Or

func Or(clauses ...Query) *or

Types

type Block

type Block struct {
	// PageSubPath is the sub path of the page this block belongs to.
	PageSubPath string

	// ID is the stable id of the block if it has one.
	ID string

	// Location is the location of the block in the page.
	Location []int

	// Preview is a preview of the block.
	Preview string
}

type BlugeIndex

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

func NewBlugeIndex

func NewBlugeIndex(graphConfig *utils.GraphConfig, indexDirectory string) (*BlugeIndex, error)

func (*BlugeIndex) Close

func (i *BlugeIndex) Close() error

func (*BlugeIndex) DeletePage

func (i *BlugeIndex) DeletePage(ctx context.Context, subPath string) error

func (*BlugeIndex) GetLastModified

func (i *BlugeIndex) GetLastModified(ctx context.Context, subPath string) (time.Time, error)

func (*BlugeIndex) IndexPage

func (i *BlugeIndex) IndexPage(ctx context.Context, page *Page) error

func (*BlugeIndex) SearchBlocks

func (i *BlugeIndex) SearchBlocks(ctx context.Context, q Query, opts SearchOptions) (SearchResults[*Block], error)

func (*BlugeIndex) SearchPages

func (i *BlugeIndex) SearchPages(ctx context.Context, q Query, opts SearchOptions) (SearchResults[*Page], error)

func (*BlugeIndex) Sync

func (i *BlugeIndex) Sync() error

type Index

type Index interface {
	// Close this index.
	Close() error

	// Sync makes sure the index has been synced and any changes are queryable.
	// Syncing may involve writing to disk.
	Sync() error

	// DeletePage removes a page from the index.
	DeletePage(ctx context.Context, subPath string) error

	// IndexPage indexes a page in the search index.
	IndexPage(ctx context.Context, doc *Page) error

	// GetLastModified returns the last modified time for a page. Should return
	// a zero time if the page does not exist in the index.
	GetLastModified(ctx context.Context, subPath string) (time.Time, error)

	// SearchPages searches for pages in the index.
	SearchPages(ctx context.Context, query Query, opts SearchOptions) (SearchResults[*Page], error)

	// SearchBlocks searches for blocks in the index.
	SearchBlocks(ctx context.Context, query Query, opts SearchOptions) (SearchResults[*Block], error)
}

type Page

type Page struct {
	// SubPath is the sub path of the page in the graph.
	SubPath string

	// Type is the type of the page.
	Type PageType

	// LastModified is the last time the page was modified on disk.
	LastModified time.Time

	// Title is the title of the page. Only used for dedicated pages.
	Title string
	// Date is the date of the journal. Only used for journals.
	Date time.Time

	// Preview string of the page, only used when searching.
	Preview string

	// Blocks is the blocks of the page, only used while indexing.
	Blocks content.BlockList
}

type PageType

type PageType int
const (
	PageTypeDedicated PageType = iota
	PageTypeJournal
)

type Query

type Query interface {
	// contains filtered or unexported methods
}

func ContentMatches

func ContentMatches(text string) Query

func LinksToURL

func LinksToURL(url string) Query

func PropertyEquals

func PropertyEquals(property string, value string) Query

func PropertyMatches

func PropertyMatches(property string, text string) Query

func PropertyReferences

func PropertyReferences(property string, target string) Query

func PropertyReferencesTag

func PropertyReferencesTag(property string, target string) Query

func References

func References(page string) Query

func ReferencesTag

func ReferencesTag(tag string) Query

func TitleMatches

func TitleMatches(text string) Query

type SearchOptions

type SearchOptions struct {
	// Size is the number of results to return.
	Size int

	// From is the offset to start returning results from.
	From int

	// SortBy is the sort order for the results.
	SortBy []SortField
}

type SearchResults

type SearchResults[V any] interface {
	// Size is the number of results available in this result set.
	Size() int

	// Count is the number of results that are available in total. For the
	// number of results available via Results, use Size.
	Count() int

	// Results is a slice of all the results in this result set.
	Results() []V
}

type SortField

type SortField struct {
	Field string
	Asc   bool
}

Jump to

Keyboard shortcuts

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