Documentation
¶
Overview ¶
Package query provides a query for zettel.
Index ¶
- func AlwaysIncluded(id.Zid) bool
- type Compiled
- type CompiledTerm
- 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 []meta.Value)
- 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 ThreadPort
- type ThreadSpec
- type UnlinkedSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlwaysIncluded ¶
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 ¶
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 ContextPort ¶
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 ¶
type ContextSpec struct {
// contains filtered or unexported fields
}
ContextSpec contains all specification values for calculating a context.
func (*ContextSpec) Execute ¶
func (spec *ContextSpec) Execute(ctx context.Context, startSeq []*meta.Meta, port ContextPort) []*meta.Meta
Execute the specification.
func (*ContextSpec) Print ¶
func (spec *ContextSpec) Print(pe *PrintEnv)
Print the spec on the given print environment.
type Directive ¶
type Directive interface {
Print(*PrintEnv)
}
Directive are executed to process the list of metadata.
type IdentSpec ¶
type IdentSpec struct{}
IdentSpec contains all specification values to calculate the ident directive.
type ItemsSpec ¶
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 ¶
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 ¶
GetDirectives returns the slice of query directives.
func (*Query) GetMetaValues ¶
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) 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 ¶
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 NFKD, trimmed and not empty.
SearchEqual(word string) *idset.Set
// Select all zettel that have a word with the given prefix.
// The prefix must be normalized through Unicode NFKD, trimmed and not empty.
SearchPrefix(prefix string) *idset.Set
// Select all zettel that have a word with the given suffix.
// The suffix must be normalized through Unicode NFKD, trimmed and not empty.
SearchSuffix(suffix string) *idset.Set
// Select all zettel that contains the given string.
// The string must be normalized through Unicode NFKD, trimmed and not empty.
SearchContains(s string) *idset.Set
}
Searcher is used to select zettel identifier based on search criteria.
type ThreadPort ¶ added in v0.22.0
ThreadPort is the collection of box methods needed by this directive.
type ThreadSpec ¶ added in v0.22.0
type ThreadSpec struct {
// contains filtered or unexported fields
}
ThreadSpec contains all information for a thread directive.
func (*ThreadSpec) Execute ¶ added in v0.22.0
func (spec *ThreadSpec) Execute(ctx context.Context, startSeq []*meta.Meta, port ThreadPort) []*meta.Meta
Execute the specification.
func (*ThreadSpec) Print ¶ added in v0.22.0
func (spec *ThreadSpec) Print(pe *PrintEnv)
Print the spec on the given print environment.
type UnlinkedSpec ¶
type UnlinkedSpec struct {
// contains filtered or unexported fields
}
UnlinkedSpec contains all specification values to calculate unlinked references.
func (*UnlinkedSpec) GetWords ¶
func (spec *UnlinkedSpec) GetWords(metaSeq []*meta.Meta) []string
GetWords returns all title words of a given query result.
func (*UnlinkedSpec) Print ¶
func (spec *UnlinkedSpec) Print(pe *PrintEnv)
Print the spec on the given print environment.