Documentation
¶
Overview ¶
Package search keeps an in-memory BM25 index (bleve) over a vault snapshot and a FAQ fast path for question-style lookups.
Index ¶
- Constants
- func Facets(s *vault.Snapshot) (types, tags map[string]int)
- func HasTerms(s string) bool
- func IsFAQ(c *okf.Concept) bool
- func Normalize(s string) string
- func Similarity(a, b string) float64
- func Snippet(body, q string, max int) string
- func TopKeys(m map[string]int) []string
- type Answer
- type Hit
- type Index
- type Query
Constants ¶
const ( Threshold = 0.6 // minimum Dice overlap between query and FAQ question terms MinCoverage = 0.75 // minimum share of the query's terms found in the FAQ question )
Thresholds for a confident FAQ answer (see vault/faq/how-does-kb-ask-decide.md).
Variables ¶
This section is empty.
Functions ¶
func HasTerms ¶ added in v0.2.0
HasTerms reports whether s has any content terms once stop words are dropped.
func Normalize ¶ added in v0.2.0
Normalize lower-cases s and keeps only letters and digits, single-spaced: the form kb_ask compares FAQ titles and aliases in.
func Similarity ¶ added in v0.2.0
Similarity is the Dice overlap of the analysed terms of a and b (0..1), the measure kb_ask matches questions with.
Types ¶
type Answer ¶
type Answer struct {
Confident bool `json:"confident"`
Confidence float64 `json:"confidence"`
Path string `json:"path,omitempty"`
Question string `json:"matched_question,omitempty"`
Answer string `json:"answer,omitempty"`
Related []Hit `json:"related,omitempty"`
}
Answer is the result of the FAQ fast path.
type Hit ¶
type Hit struct {
Path string `json:"path"`
Title string `json:"title"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Tickets []string `json:"tickets,omitempty"`
Snippet string `json:"snippet,omitempty"`
Score float64 `json:"score"`
}
Hit is a compact search result.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index is a swappable in-memory search index.
func (*Index) Ask ¶
Ask answers a question from FAQ entries when it is confident; otherwise it returns the best search hits so the agent can read further.
Confident means: the normalised question equals an FAQ title or alias, or the Dice overlap of analysed terms is >= Threshold AND the FAQ question covers >= MinCoverage of the query's terms. Coverage stops a one-keyword FAQ ("What is okvault?") from capturing "what is the okvault license?".
type Query ¶
type Query struct {
Text string
Type string
Tags []string
Dir string
Ticket string // only notes linked to or mentioning this ticket key
Owner string // only notes owned by this person or group
Limit int
WithDeprecated bool
// NearTickets ranks notes about these ticket keys, and notes one link
// from them, a little higher. Ticket keys in Text count too.
NearTickets []string
}
Query is a search request.