Documentation
¶
Overview ¶
Package query provides a query for zettel.
Index ¶
- func AlwaysIncluded(id.Zid) bool
- type Compiled
- type CompiledTerm
- type ContextDirection
- type ContextPort
- type ContextSpec
- type Directive
- type IdentSpec
- type ItemsSpec
- type MetaMatchFunc
- type PrintEnv
- type Query
- func (q *Query) Actions() []string
- func (q *Query) Clone() *Query
- func (q *Query) EnrichNeeded() bool
- func (q *Query) GetDirectives() []Directive
- func (q *Query) GetMetaValues(key string, withMissing bool) (vals []string)
- func (q *Query) GetSeed() (int, bool)
- func (q *Query) GetZids() []id.Zid
- func (q *Query) Human() string
- func (q *Query) Limit(metaList []*meta.Meta) []*meta.Meta
- func (q *Query) Parse(spec string) *Query
- func (q *Query) Print(w io.Writer)
- func (q *Query) PrintHuman(w io.Writer)
- func (q *Query) RemoveActions()
- func (q *Query) RetrieveAndCompile(_ context.Context, searcher Searcher, metaSeq []*meta.Meta) Compiled
- func (q *Query) SetDeterministic() *Query
- func (q *Query) SetPreMatch(preMatch MetaMatchFunc) *Query
- func (q *Query) SetSeed(seed int) *Query
- func (q *Query) String() string
- type RetrievePredicate
- type Searcher
- type UnlinkedSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlwaysIncluded ¶ added in v0.14.0
AlwaysIncluded is a RetrievePredicate that always returns true.
Types ¶
type Compiled ¶
type Compiled struct { PreMatch MetaMatchFunc // Precondition for Match and Retrieve Terms []CompiledTerm // contains filtered or unexported fields }
Compiled is a compiled query, to be used in a Box
func (*Compiled) AfterSearch ¶ added in v0.12.0
AfterSearch applies all terms to the metadata list that was searched.
This includes sorting, offset, limit, and picking.
type CompiledTerm ¶
type CompiledTerm struct { Match MetaMatchFunc // Match on metadata Retrieve RetrievePredicate // Retrieve from full-text search }
CompiledTerm is the preprocessed sequence of conjugated search terms.
type ContextDirection ¶ added in v0.13.0
type ContextDirection uint8
ContextDirection specifies the direction a context should be calculated.
const ( ContextDirBoth ContextDirection = iota ContextDirForward ContextDirBackward )
type ContextPort ¶ added in v0.13.0
type ContextPort interface { GetMeta(ctx context.Context, zid id.Zid) (*meta.Meta, error) SelectMeta(ctx context.Context, metaSeq []*meta.Meta, q *Query) ([]*meta.Meta, error) }
ContextPort is the collection of box methods needed by this directive.
type ContextSpec ¶ added in v0.13.0
type ContextSpec struct { Direction ContextDirection MaxCost int MaxCount int Full bool }
ContextSpec contains all specification values for calculating a context.
func (*ContextSpec) Execute ¶ added in v0.13.0
func (spec *ContextSpec) Execute(ctx context.Context, startSeq []*meta.Meta, port ContextPort) []*meta.Meta
func (*ContextSpec) Print ¶ added in v0.13.0
func (spec *ContextSpec) Print(pe *PrintEnv)
type Directive ¶ added in v0.13.0
type Directive interface {
Print(*PrintEnv)
}
Directive are executed to process the list of metadata.
type IdentSpec ¶ added in v0.13.0
type IdentSpec struct{}
IdentSpec contains all specification values to calculate the ident directive.
type ItemsSpec ¶ added in v0.13.0
type ItemsSpec struct{}
ItemsSpec contains all specification values to calculate items.
type MetaMatchFunc ¶
MetaMatchFunc is a function determine whethe some metadata should be selected or not.
type PrintEnv ¶ added in v0.13.0
type PrintEnv struct {
// contains filtered or unexported fields
}
PrintEnv is an environment where queries are printed.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query specifies a mechanism for querying zettel.
func (*Query) EnrichNeeded ¶
EnrichNeeded returns true, if the query references a metadata key that is calculated via metadata enrichments.
func (*Query) GetDirectives ¶ added in v0.13.0
GetDirectives returns the slice of query directives.
func (*Query) GetMetaValues ¶ added in v0.14.0
GetMetaValues returns the slice of all values specified for a given metadata key. If `withMissing` is true, all values are returned. Otherwise only those, where the comparison operator will positively search for a value.
func (*Query) GetZids ¶ added in v0.13.0
GetZids returns a slide of all specified zettel identifier.
func (*Query) PrintHuman ¶
PrintHuman the query to a writer in a human readable form.
func (*Query) RemoveActions ¶
func (q *Query) RemoveActions()
RemoveActions will remove the action part of a query.
func (*Query) RetrieveAndCompile ¶
func (q *Query) RetrieveAndCompile(_ context.Context, searcher Searcher, metaSeq []*meta.Meta) Compiled
RetrieveAndCompile queries the search index and returns a predicate for its results and returns a matching predicate.
func (*Query) SetDeterministic ¶ added in v0.12.0
SetDeterministic signals that the result should be the same if the seed is the same.
func (*Query) SetPreMatch ¶
func (q *Query) SetPreMatch(preMatch MetaMatchFunc) *Query
SetPreMatch sets the pre-selection predicate.
type RetrievePredicate ¶
RetrievePredicate returns true, if the given Zid is contained in the (full-text) search.
type Searcher ¶
type Searcher interface { // Select all zettel that contains the given exact word. // The word must be normalized through Unicode NKFD, trimmed and not empty. SearchEqual(word string) *id.Set // Select all zettel that have a word with the given prefix. // The prefix must be normalized through Unicode NKFD, trimmed and not empty. SearchPrefix(prefix string) *id.Set // Select all zettel that have a word with the given suffix. // The suffix must be normalized through Unicode NKFD, trimmed and not empty. SearchSuffix(suffix string) *id.Set // Select all zettel that contains the given string. // The string must be normalized through Unicode NKFD, trimmed and not empty. SearchContains(s string) *id.Set }
Searcher is used to select zettel identifier based on search criteria.
type UnlinkedSpec ¶ added in v0.13.0
type UnlinkedSpec struct {
// contains filtered or unexported fields
}
UnlinkedSpec contains all specification values to calculate unlinked references.
func (*UnlinkedSpec) GetWords ¶ added in v0.13.0
func (spec *UnlinkedSpec) GetWords(metaSeq []*meta.Meta) []string
func (*UnlinkedSpec) Print ¶ added in v0.13.0
func (spec *UnlinkedSpec) Print(pe *PrintEnv)