Documentation ¶
Index ¶
- func CreateNewDatabase() error
- func CumulativeTermsCount(id uuid.UUID) (int, error)
- func DownCase(words []string) []string
- func DropIndex() error
- func FlattenString(input string) string
- func GetAllSnipIDs() ([]uuid.UUID, error)
- func GetAttachmentsAll() ([]uuid.UUID, error)
- func GetAttachmentsUUID(snipUUID uuid.UUID) ([]uuid.UUID, error)
- func GetIndexTermCount(term string, id uuid.UUID) (int, error)
- func InsertSnip(s Snip) error
- func IsWord(word string) bool
- func Remove(id uuid.UUID) error
- func RemoveAttachment(id uuid.UUID) error
- func ScoreCounts(id uuid.UUID, terms []string, counts []SearchCount) (float64, error)
- func SearchIndexTerm(terms []string, requireAll bool) (map[uuid.UUID][]SearchCount, error)
- func ShortenUUID(id uuid.UUID) []string
- func SplitWords(data string) []string
- func StripPunctuation(words []string) []string
- func WriteAttachment(id uuid.UUID, outfile string, forceWrite bool) (int, error)
- type Attachment
- type SearchCount
- type SearchResult
- type SearchScore
- type Snip
- func (s *Snip) Attach(name string, data []byte) error
- func (s *Snip) CountWords() int
- func (s *Snip) GatherContext(term string, adjacent int) ([]TermContext, error)
- func (s *Snip) GenerateName(wordCount int) string
- func (s *Snip) GetPositions(term string) (string, error)
- func (s *Snip) Index() error
- func (s *Snip) Rename(newName string) error
- func (s *Snip) SetIndexTermCount(term string, count int) error
- func (s *Snip) SetPositions(term string, positions []int) error
- func (s *Snip) Update() error
- type TermContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNewDatabase ¶
func CreateNewDatabase() error
CreateNewDatabase creates a new sqlite3 database
func CumulativeTermsCount ¶
CumulativeTermsCount returns a total of all occurrences of all known terms in a document's search index
func FlattenString ¶
FlattenString returns a string with all newline, tabs, and spaces squeezed
func GetAllSnipIDs ¶
GetAllSnipIDs returns a slice of all known snip uuids
func GetAttachmentsAll ¶
GetAttachmentsAll returns a slice of uuids for all attachments in the system
func GetAttachmentsUUID ¶
GetAttachmentsUUID returns a slice of attachment uuids associated with supplied snip uuid
func GetIndexTermCount ¶
GetIndexTermCount returns the index count for a term matching id
func RemoveAttachment ¶
RemoveAttachment deletes an attachment from the database
func ScoreCounts ¶
ScoreCounts returns a floating point score for search result validity
func SearchIndexTerm ¶
SearchIndexTerm searches the index and returns results matching the given term
func ShortenUUID ¶
func SplitWords ¶
SplitWords splits words using unicode standard splitting functions
func StripPunctuation ¶
StripPunctuation strips all commas, periods, etc. from a slice of strings
Types ¶
type Attachment ¶
type Attachment struct { UUID uuid.UUID Data []byte Size int SnipUUID uuid.UUID Timestamp time.Time Name string }
Attachment represents data (binary safe) associated with a specific snip
func GetAttachmentFromUUID ¶
func GetAttachmentFromUUID(searchUUID string) (Attachment, error)
func GetAttachmentMetadata ¶
func GetAttachmentMetadata(searchUUID uuid.UUID) (Attachment, error)
GetAttachmentMetadata returns all fields except Data for analysis without large memory use
func GetAttachments ¶
func GetAttachments(searchUUID uuid.UUID) ([]Attachment, error)
GetAttachments returns a slice of Attachment associated with the supplied snip uuid
func NewAttachment ¶
func NewAttachment() Attachment
NewAttachment returns a new attachment struct with current defaults
type SearchCount ¶
SearchCount contains info about a search term frequency from the index
type SearchResult ¶
type SearchResult struct { UUID uuid.UUID Terms []SearchCount }
type SearchScore ¶
type SearchScore struct { UUID uuid.UUID Score float64 SearchCounts []SearchCount }
type Snip ¶
type Snip struct { Attachments []Attachment Data string Timestamp time.Time Name string UUID uuid.UUID }
Snip represents a snippet of data with additional metadata
func GetFromUUID ¶
GetFromUUID retrieves a single Snip by its unique identifier
func SearchDataTerm ¶
SearchDataTerm returns a slice of Snips whose data matches supplied terms
func SearchUUID ¶
SearchUUID returns a slice of Snips with uuids matching partial search term
func (*Snip) CountWords ¶
CountWords returns an integer estimating the number of words in data
func (*Snip) GatherContext ¶
func (s *Snip) GatherContext(term string, adjacent int) ([]TermContext, error)
GatherContext returns the surrounding words matching the given term
func (*Snip) GenerateName ¶
GenerateName returns a clean string derived from processing the data field
func (*Snip) GetPositions ¶
GetPositions gets the position indicators for a given term
func (*Snip) SetIndexTermCount ¶
SetIndexTermCount inserts or updates the count of a term indexed
func (*Snip) SetPositions ¶
SetPositions writes the word positions of a given term