Documentation
¶
Overview ¶
Package fulltext uses a full-text search engine to index, and search the content of the markdown textfiles used within the application.
Currently, the index is built at startup and stored in RAM as the number of files to catalog is low. However, if we were to expand the indexing to file downloads a different approach is needed.
Index ¶
- Constants
- Variables
- func Snippet(query, body string, wordWindow int) string
- type Index
- type Result
- type Tidbits
- func (ts *Tidbits) Add(filename, body string) error
- func (ts *Tidbits) Body(docID int) string
- func (ts *Tidbits) Name(docID int) string
- func (ts *Tidbits) New()
- func (ts *Tidbits) NewIndex(fsys embed.FS, root string) error
- func (ts *Tidbits) Search(query string, maxResults int) []Result
- func (ts *Tidbits) Stores() int
Constants ¶
const Window = 40 // Window is number of characters to display either side of a snippet
Variables ¶
Functions ¶
Types ¶
type Tidbits ¶
type Tidbits struct {
TotalDocs int // Total number of indexed documents
TotalTerms int64 // Total number of terms across all docs
// contains filtered or unexported fields
}
Tidbits are the index for the group biographies stored as markdown texts.
func (*Tidbits) Add ¶
Add both the filename and body to the Tidbits index. There are no checks for the validity of the arguments,
However, errors will return when:
- the index has not been created
- the filename is empty
- the body trimmed of white space is empty
func (*Tidbits) Body ¶
Body value of the document id is returned from the index. If the id doesn't exist, an empty string is returned.
func (*Tidbits) Name ¶
Name value of the document id is returned from the index. If the id doesn't exist, an "error" string is returned.
func (*Tidbits) NewIndex ¶
NewIndex indexes all the files found in the root directory of the fsys embed file system.
Note, it will overwrite any existing indexing. The blaze library annoyingly slogs every index added, so this func temporary mutes all slogs while indexing.