Documentation
¶
Overview ¶
Package query contains the API for creating Zoekt queries. Queries can be constructed directly through query.Q objects, or by parsing a string using query.Parse
Index ¶
- Constants
- func LowerRegexp(r *syntax.Regexp) *syntax.Regexp
- func OptimizeRegexp(re *syntax.Regexp, flags syntax.Flags) *syntax.Regexp
- func VisitAtoms(q Q, v func(q Q))
- type And
- type Boost
- type Branch
- type BranchRepos
- type BranchesRepos
- type Const
- type FileNameSet
- type Language
- type Meta
- type Not
- type Or
- type Q
- type RawConfig
- type Regexp
- type Repo
- type RepoIDs
- type RepoRegexp
- type RepoSet
- type Substring
- type Symbol
- type Type
Constants ¶
const ( TypeFileMatch uint8 = iota TypeFileName TypeRepo )
Variables ¶
This section is empty.
Functions ¶
func OptimizeRegexp ¶
OptimizeRegexp converts capturing groups to non-capturing groups. Returns original input if an error is encountered
func VisitAtoms ¶
VisitAtoms runs `v` on all atom queries within `q`.
Types ¶
type Boost ¶
type Boost struct {
Child Q
// Boost will multiply the score of its descendants. Values less than 1 will
// give less importance while values greater than 1 will give more
// importance.
Boost float64
}
Boost scales the contribution to score of descendants.
type Branch ¶
type Branch struct {
Pattern string
// exact is true if we want to Pattern to equal branch.
Exact bool
}
Branch limits search to a specific branch.
type BranchRepos ¶
BranchRepos is a (branch, sourcegraph repo ids bitmap) tuple. It is a Sourcegraph addition.
type BranchesRepos ¶
type BranchesRepos struct {
List []BranchRepos
}
BranchesRepos is a slice of BranchRepos to match. It is a Sourcegraph addition and only used in the RPC interface for efficient checking of large repo lists.
func NewSingleBranchesRepos ¶
func NewSingleBranchesRepos(branch string, ids ...uint32) *BranchesRepos
NewSingleBranchesRepos is a helper for creating a BranchesRepos which searches a single branch.
func (BranchesRepos) MarshalBinary ¶
func (q BranchesRepos) MarshalBinary() ([]byte, error)
MarshalBinary implements a specialized encoder for BranchesRepos.
func (*BranchesRepos) String ¶
func (q *BranchesRepos) String() string
func (*BranchesRepos) UnmarshalBinary ¶
func (q *BranchesRepos) UnmarshalBinary(b []byte) (err error)
UnmarshalBinary implements a specialized decoder for BranchesRepos.
type FileNameSet ¶
type FileNameSet struct {
Set map[string]struct{}
}
FileNameSet is a list of file names to match. It is a Sourcegraph addition and only used in the RPC interface for efficient checking of large file lists.
func NewFileNameSet ¶
func NewFileNameSet(fileNames ...string) *FileNameSet
func (*FileNameSet) MarshalBinary ¶
func (q *FileNameSet) MarshalBinary() ([]byte, error)
MarshalBinary implements a specialized encoder for FileNameSet.
func (*FileNameSet) String ¶
func (q *FileNameSet) String() string
func (*FileNameSet) UnmarshalBinary ¶
func (q *FileNameSet) UnmarshalBinary(b []byte) error
UnmarshalBinary implements a specialized decoder for FileNameSet.
type Meta ¶
type Meta struct {
Field string // The metadata field name
Value *regexp.Regexp // The value to match
}
Meta represents a query for metadata fields.
type Q ¶
type Q interface {
String() string
}
Q is a representation for a possibly hierarchical search query.
func ExpandFileContent ¶
Expand expands Substr queries into (OR file_substr content_substr) queries, and the same for Regexp queries..
func RegexpQuery ¶
RegexpQuery parses an atom into either a regular expression, or a simple substring atom.
type RawConfig ¶
type RawConfig uint64
RawConfig filters repositories based on their encoded RawConfig map.
type Regexp ¶
RegexpQuery is a query looking for regular expressions matches.
type RepoIDs ¶
Similar to BranchRepos but will be used to match only by repoid and therefore matches all branches
func NewRepoIDs ¶
NewRepoIDs is a helper for creating a RepoIDs which searches only the matched repos.
type RepoRegexp ¶
RepoRegexp is a Sourcegraph addition which searches documents where the repository name matches Regexp.
func (*RepoRegexp) GobDecode ¶
func (q *RepoRegexp) GobDecode(data []byte) error
GobDecode implements gob.Decoder.
func (*RepoRegexp) GobEncode ¶
func (q *RepoRegexp) GobEncode() ([]byte, error)
GobEncode implements gob.Encoder.
func (*RepoRegexp) String ¶
func (q *RepoRegexp) String() string
type RepoSet ¶
RepoSet is a list of repos to match. It is a Sourcegraph addition and only used in the RPC interface for efficient checking of large repo lists.
func NewRepoSet ¶
type Substring ¶
type Substring struct {
Pattern string
CaseSensitive bool
// Match only filename
FileName bool
// Match only content
Content bool
}
Substring is the most basic query: a query for a substring.