Documentation ¶
Index ¶
- Constants
- func LowerRegexp(r *syntax.Regexp) *syntax.Regexp
- func OptimizeRegexp(re *syntax.Regexp, flags syntax.Flags) *syntax.Regexp
- func QToProto(q Q) *proto.Q
- func VisitAtoms(q Q, v func(q Q))
- type And
- type Boost
- type Branch
- type BranchRepos
- type BranchesRepos
- type Const
- type ExperimentalPhraseBoostOptions
- type FileNameSet
- type GobCache
- type Language
- type Not
- type Or
- type Q
- func ExpandFileContent(q Q) Q
- func ExpirementalPhraseBoost(q Q, phrase string, opts ExperimentalPhraseBoostOptions) Q
- func Map(q Q, f func(q Q) Q) Q
- func NewAnd(qs ...Q) Q
- func NewOr(qs ...Q) Q
- func Parse(qStr string) (Q, error)
- func QFromProto(p *proto.Q) (Q, error)
- func RPCUnwrap(q Q) Q
- func RegexpQuery(text string, content, file bool) (Q, error)
- func Simplify(q Q) 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 descendents. 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 descendents.
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.
func BranchFromProto ¶
type BranchRepos ¶
BranchRepos is a (branch, sourcegraph repo ids bitmap) tuple. It is a Sourcegraph addition.
func BranchReposFromProto ¶
func BranchReposFromProto(p *proto.BranchRepos) (BranchRepos, error)
func (*BranchRepos) ToProto ¶
func (br *BranchRepos) ToProto() *proto.BranchRepos
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 BranchesReposFromProto ¶
func BranchesReposFromProto(p *proto.BranchesRepos) (*BranchesRepos, error)
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) ToProto ¶
func (br *BranchesRepos) ToProto() *proto.BranchesRepos
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 FileNameSetFromProto ¶
func FileNameSetFromProto(p *proto.FileNameSet) *FileNameSet
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) ToProto ¶
func (q *FileNameSet) ToProto() *proto.FileNameSet
func (*FileNameSet) UnmarshalBinary ¶
func (q *FileNameSet) UnmarshalBinary(b []byte) error
UnmarshalBinary implements a specialized decoder for FileNameSet.
type GobCache ¶
type GobCache struct { Q // contains filtered or unexported fields }
GobCache exists so we only pay the cost of marshalling a query once when we aggregate it out over all the replicas.
Our query and eval layer do not support GobCache. Instead, at the gob boundaries (RPC and Streaming) we check if the Q is a GobCache and unwrap it.
"I wish we could get rid of this code soon enough" - tomas
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 ExpirementalPhraseBoost ¶
func ExpirementalPhraseBoost(q Q, phrase string, opts ExperimentalPhraseBoostOptions) Q
ExperimentalPhraseBoost transforms q into a query containing exact matches to phrase boosted. opts control how and when the boosting is done.
Note: This is a temporary API and will be removed in future commits.
func RPCUnwrap ¶
RPCUnwrap processes q to remove RPC specific elements from q. This is needed because gob isn't flexible enough for us. This should be called by RPC servers at the client/server boundary so that q works with the rest of zoekt.
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.
func RawConfigFromProto ¶
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 RepoRegexpFromProto ¶
func RepoRegexpFromProto(p *proto.RepoRegexp) (*RepoRegexp, error)
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
func (*RepoRegexp) ToProto ¶
func (q *RepoRegexp) ToProto() *proto.RepoRegexp
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 ¶
func RepoSetFromProto ¶
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.