Documentation
¶
Index ¶
- Variables
- func SortByRelevance(results []SearchResult, query string)
- type Client
- func (c *Client) AppendBlockInPage(_ context.Context, page string, content string) (*types.BlockEntity, error)
- func (c *Client) BuildBacklinks()
- func (c *Client) Close() error
- func (c *Client) CreatePage(_ context.Context, name string, properties map[string]any, opts map[string]any) (*types.PageEntity, error)
- func (c *Client) DatascriptQuery(_ context.Context, query string, inputs ...any) (json.RawMessage, error)
- func (c *Client) DeletePage(_ context.Context, name string) error
- func (c *Client) FindBlocksByTag(_ context.Context, tag string, includeChildren bool) ([]backend.TagResult, error)
- func (c *Client) FindByProperty(_ context.Context, key, value, operator string) ([]backend.PropertyResult, error)
- func (c *Client) FullTextSearch(_ context.Context, query string, limit int) ([]backend.SearchHit, error)
- func (c *Client) GetAllPages(_ context.Context) ([]types.PageEntity, error)
- func (c *Client) GetBlock(_ context.Context, uuid string, opts ...map[string]any) (*types.BlockEntity, error)
- func (c *Client) GetPage(_ context.Context, nameOrID any) (*types.PageEntity, error)
- func (c *Client) GetPageBlocksTree(_ context.Context, nameOrID any) ([]types.BlockEntity, error)
- func (c *Client) GetPageLinkedReferences(_ context.Context, nameOrID any) (json.RawMessage, error)
- func (c *Client) InsertBlock(_ context.Context, srcBlock any, content string, opts map[string]any) (*types.BlockEntity, error)
- func (c *Client) Load() error
- func (c *Client) MoveBlock(_ context.Context, uuid string, targetUUID string, opts map[string]any) error
- func (c *Client) Ping(_ context.Context) error
- func (c *Client) PrependBlockInPage(_ context.Context, page string, content string) (*types.BlockEntity, error)
- func (c *Client) Reload() error
- func (c *Client) RemoveBlock(_ context.Context, uuid string) error
- func (c *Client) RenamePage(_ context.Context, oldName, newName string) error
- func (c *Client) SearchJournals(_ context.Context, query, from, to string) ([]backend.JournalResult, error)
- func (c *Client) UpdateBlock(_ context.Context, uuid string, content string, opts ...map[string]any) error
- func (c *Client) Watch() error
- type Option
- type SearchIndex
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupported = fmt.Errorf("operation not supported by obsidian backend")
ErrNotSupported is returned for Logseq-specific operations (DataScript queries).
var ErrPathEscape = fmt.Errorf("path escapes vault boundary")
ErrPathEscape is returned when a resolved path escapes the vault boundary.
Functions ¶
func SortByRelevance ¶ added in v0.4.0
func SortByRelevance(results []SearchResult, query string)
SortByRelevance sorts search results by term frequency. Not currently used but available for future ranking improvements.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements backend.Backend for an Obsidian vault on disk. It reads all .md files on initialization and serves queries from memory.
func (*Client) AppendBlockInPage ¶
func (*Client) BuildBacklinks ¶
func (c *Client) BuildBacklinks()
BuildBacklinks must be called after Load() to build the reverse link index.
func (*Client) CreatePage ¶
func (*Client) DatascriptQuery ¶
func (*Client) DeletePage ¶ added in v0.4.0
func (*Client) FindBlocksByTag ¶
func (c *Client) FindBlocksByTag(_ context.Context, tag string, includeChildren bool) ([]backend.TagResult, error)
FindBlocksByTag scans all pages for blocks containing the given #tag. Implements backend.TagSearcher.
func (*Client) FindByProperty ¶
func (c *Client) FindByProperty(_ context.Context, key, value, operator string) ([]backend.PropertyResult, error)
FindByProperty scans all pages for matching frontmatter properties. Implements backend.PropertySearcher.
func (*Client) FullTextSearch ¶ added in v0.4.0
func (c *Client) FullTextSearch(_ context.Context, query string, limit int) ([]backend.SearchHit, error)
FullTextSearch uses the inverted index for efficient full-text search. Implements backend.FullTextSearcher.
func (*Client) GetAllPages ¶
func (*Client) GetPageBlocksTree ¶
func (*Client) GetPageLinkedReferences ¶
func (*Client) InsertBlock ¶
func (*Client) PrependBlockInPage ¶
func (*Client) RenamePage ¶ added in v0.4.0
func (*Client) SearchJournals ¶
func (c *Client) SearchJournals(_ context.Context, query, from, to string) ([]backend.JournalResult, error)
SearchJournals scans daily notes for matching content. Implements backend.JournalSearcher.
func (*Client) UpdateBlock ¶
type Option ¶
type Option func(*Client)
Option configures a vault Client.
func WithDailyFolder ¶
WithDailyFolder sets the daily notes subfolder (default: "daily notes").
type SearchIndex ¶ added in v0.4.0
type SearchIndex struct {
// contains filtered or unexported fields
}
SearchIndex is a simple inverted index for full-text search. Maps lowercase terms to the blocks containing them.
func NewSearchIndex ¶ added in v0.4.0
func NewSearchIndex() *SearchIndex
NewSearchIndex creates an empty search index.
func (*SearchIndex) BuildFrom ¶ added in v0.4.0
func (si *SearchIndex) BuildFrom(pages map[string]*cachedPage)
BuildFrom indexes all pages in the vault.
func (*SearchIndex) ReindexPage ¶ added in v0.4.0
func (si *SearchIndex) ReindexPage(page *cachedPage)
ReindexPage removes and re-adds a single page to the index.
func (*SearchIndex) RemovePage ¶ added in v0.4.0
func (si *SearchIndex) RemovePage(lowerName string)
RemovePage removes a page from the index.
func (*SearchIndex) Search ¶ added in v0.4.0
func (si *SearchIndex) Search(query string, limit int) []SearchResult
Search finds blocks matching all terms in the query (AND semantics). Returns results sorted by relevance (number of term hits).
type SearchResult ¶ added in v0.4.0
type SearchResult struct {
PageName string `json:"page"`
UUID string `json:"uuid"`
Content string `json:"content"`
}
SearchResult is a block that matched a search query.