Documentation
¶
Overview ¶
Package search provides search functionality via the Entire search service.
Index ¶
- Constants
- Variables
- func AppendUnique(existing []string, values ...string) []string
- func ParseGitHubRemote(remoteURL string) (owner, repo string, err error)
- func ValidateRepoFilters(repos []string) error
- type CheckpointResult
- type CommitResult
- type Config
- type HTTPStatusError
- type MalformedResponseError
- type Meta
- type ParsedInput
- type Response
- type Result
- func (r *Result) DedupID() string
- func (r *Result) MarshalJSON() ([]byte, error)
- func (r *Result) ResultAuthor() string
- func (r *Result) ResultBranch() string
- func (r *Result) ResultCheckpointCount() int
- func (r *Result) ResultCreatedAt() string
- func (r *Result) ResultID() string
- func (r *Result) ResultOrg() string
- func (r *Result) ResultRepo() string
- func (r *Result) ResultTitle() string
- func (r *Result) UnmarshalJSON(b []byte) error
- type SessionResult
- type Timing
- type TypeCounts
Constants ¶
const ( TypeCheckpoint = "checkpoint" TypeCommit = "commit" TypeSession = "session" // TypeRepo and TypePR are returned by the backend but have no typed struct // (decoded via rawData). They're named so the cross-cell v4 merge can bucket // and tally them without string literals. TypeRepo = "repo" TypePR = "pr" )
Result type constants.
const AllReposFilter = "*"
AllReposFilter is the inline repo filter value that disables repo scoping.
const DefaultLimit = 100
DefaultLimit is the default number of results to fetch per request, matching the UI.
const WildcardQuery = "*"
WildcardQuery is the query string used when only filters are provided (no search terms).
Variables ¶
ErrCellUnavailable reports that a cell's gateway does not expose the semantic-search route at all (HTTP 404 at the route level) — query-serve is not deployed in that cell yet. Callers fanning out across cells match it with errors.Is and skip the cell quietly instead of warning the user about a "failed" region.
var ErrRepoFilterUnmatched = errors.New("no requested repo was found in this cell")
ErrRepoFilterUnmatched reports that query-serve answered (the route exists) but the explicit repo filter matched nothing the caller can search. The repository might not be indexed yet. A typo'd repo can't produce this from the CLI: the slug was already resolved against the control-plane index before any cell was contacted. Distinct from ErrCellUnavailable so fan-out callers don't misreport a repo-level miss as a region without query-serve.
Functions ¶
func AppendUnique ¶ added in v0.9.0
AppendUnique appends values to existing, skipping any already present, and returns the result. Order is preserved (first occurrence wins).
func ParseGitHubRemote ¶
ParseGitHubRemote extracts owner and repo from a git remote URL that resolves to GitHub. It accepts direct GitHub remotes (SCP-style SSH, ssh://, and https://) as well as Entire mirror remotes (entire://host/gh/owner/repo), whose forge prefix maps back to github.com. Remotes resolving to any other host, or whose path holds extra segments beyond owner/repo, are rejected.
func ValidateRepoFilters ¶
ValidateRepoFilters ensures each repo filter matches backend semantics. Multiple explicit repo filters are accepted: the v4 query-serve path resolves each and fans out across the cells hosting them, mirroring code search.
Types ¶
type CheckpointResult ¶
type CheckpointResult struct {
ID string `json:"id"`
Prompt string `json:"prompt"`
CommitMessage *string `json:"commitMessage"`
CommitSubject *string `json:"commitSubject"`
CommitSHA *string `json:"commitSha"`
Branch string `json:"branch"`
Org string `json:"org"`
Repo string `json:"repo"`
Author string `json:"author"`
AuthorUsername *string `json:"authorUsername"`
CreatedAt string `json:"createdAt"`
FilesTouched []string `json:"filesTouched"`
}
CheckpointResult represents a checkpoint returned by the search service.
type CommitResult ¶ added in v0.7.6
type CommitResult struct {
ID string `json:"id"`
CommitSHA string `json:"commitSha"`
CommitMessage string `json:"commitMessage"`
CommitSubject string `json:"commitSubject"`
Branch string `json:"branch"`
Org string `json:"org"`
Repo string `json:"repo"`
Author string `json:"author"`
AuthorUsername *string `json:"authorUsername"`
CreatedAt string `json:"createdAt"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
FilesChanged int `json:"filesChanged"`
HTMLUrl *string `json:"htmlUrl"`
}
CommitResult represents a commit returned by the search service.
type Config ¶
type Config struct {
Owner string
Repo string
Repos []string
AllRepos bool // When true, search all accessible repos (no repo scoping)
Query string
Limit int
Author string // Filter by author name
Date string // Filter by time period: "week" or "month"
Branch string // Filter by branch name
Page int // 1-based page number (0 means omit, API defaults to 1)
}
Config holds the configuration for a search request.
func (Config) HasFilters ¶
HasFilters reports whether any filter fields are set on the config.
func (Config) ScopeSlugs ¶ added in v0.9.0
ScopeSlugs resolves the repo scope of a search: the explicit repo filters (an explicit owner/name filter always scopes the search, even when --all-repos is also set — the more specific filter wins), else allRepos for an unfiltered repo:* / --all-repos search, else the current-repo default. slugs empty with allRepos false means no scope could be determined.
type HTTPStatusError ¶ added in v0.10.3
HTTPStatusError reports a non-OK search-service response. It preserves the long-standing message wording (asserted by callers and tests) while exposing the status code so outcome telemetry can classify server errors from the type rather than the message text (ENT-1938).
func (*HTTPStatusError) Error ¶ added in v0.10.3
func (e *HTTPStatusError) Error() string
type MalformedResponseError ¶ added in v0.10.3
type MalformedResponseError struct {
Message string
}
MalformedResponseError reports a 200 whose body was not a usable search response: undecodable JSON, or a decoded body carrying an application-level error field. Typed for the same reason as HTTPStatusError — the service answered unusably, which outcome telemetry counts as a server failure, not an unclassified one. Message wording is preserved verbatim.
func (*MalformedResponseError) Error ¶ added in v0.10.3
func (e *MalformedResponseError) Error() string
type Meta ¶
type Meta struct {
MatchType string `json:"matchType"`
Score float64 `json:"score"`
Tier *int `json:"tier,omitempty"`
Snippet string `json:"snippet,omitempty"`
Summary string `json:"summary,omitempty"`
// RerankScore is query-serve's cross-encoder (Cohere) relevance judgement,
// present only on results that went through reranking. Where present it is
// the signal the final ordering was built from and the only score
// comparable across repos — Score is per-namespace retrieval strength, so
// sorting by it undoes reranking. The cross-cell merge orders tier 0 and
// tier 1 by this field, matching the BFF (ENT-1425/ENT-1431).
RerankScore *float64 `json:"rerankScore,omitempty"`
BM25Score *float64 `json:"bm25Score,omitempty"`
ANNScore *float64 `json:"annScore,omitempty"`
}
Meta contains search ranking metadata for a result.
type ParsedInput ¶
ParsedInput holds the parsed query and optional filters extracted from search input.
func ParseSearchInput ¶
func ParseSearchInput(raw string) ParsedInput
ParseSearchInput extracts filter prefixes from raw input. Supports quoted values for single-value filters, for example: author:"alice smith". Remaining tokens become the query.
type Response ¶
type Response struct {
Results []Result `json:"results"`
Total int `json:"total"`
Page int `json:"page"`
Error string `json:"error,omitempty"`
Timing *Timing `json:"timing,omitempty"`
Reranked *bool `json:"reranked,omitempty"`
Counts *TypeCounts `json:"counts,omitempty"`
// Completeness metadata, same names and semantics as the BFF's merged
// response (entire.io api/src/routes/search.ts mergeCellResponses) so web
// and CLI surface identical signals (ENT-1777). Parsed from each cell and
// re-synthesized by the CLI's own merge.
Partial bool `json:"partial,omitempty"`
Truncated bool `json:"truncated,omitempty"`
CoverageIncomplete bool `json:"coverage_incomplete,omitempty"`
TruncatedTypes map[string]bool `json:"truncated_types,omitempty"`
CountsLowerBound map[string]bool `json:"counts_lower_bound,omitempty"`
// Warnings are client-side completeness notes (e.g. a truncated repo
// index or a failed region in a cross-cell fan-out) surfaced to the user
// on stderr. Never part of the wire format.
Warnings []string `json:"-"`
}
Response is the search service response.
func CellV4 ¶ added in v0.9.0
func CellV4(ctx context.Context, client *api.Client, cfg Config, repoIDs []string) (*Response, error)
CellV4 performs a v4 query-serve search against a single entire-api cell, via the pre-authenticated client (bearer = jurisdictional identity token; host = the cell). repoIDs are repo ULIDs to scope to (the v4 route is per-repo and keys on ULIDs, not owner/name slugs); an empty repoIDs means "every repo the caller can access in this cell" — query-serve fans out across those namespaces itself. The cross-cell fan-out and merge live in the cli layer (mirroring code search), so this is the single-cell primitive it calls.
type Result ¶
type Result struct {
Type string `json:"-"`
Meta Meta `json:"-"`
Checkpoint *CheckpointResult `json:"-"`
Commit *CommitResult `json:"-"`
Session *SessionResult `json:"-"`
// contains filtered or unexported fields
}
Result wraps a search result with its type and ranking metadata. Exactly one of Checkpoint, Commit, or Session is non-nil based on Type.
func (*Result) DedupID ¶ added in v0.10.1
DedupID is the identity used to collapse cross-cell duplicates. It matches ResultID except for the id types that can REPEAT across repos, which it repo-qualifies so two repos' rows sharing an id don't collide in the deduper and drop a valid result:
- a raw checkpoint id, and the checkpoint id a server-folded legacy session (ENT-1595) falls back to — checkpoint ids are a mixed space (legacy 12-hex ids repeat across repos; newer ULIDs are global), so qualifying by repo is safe for both and necessary for the legacy half;
- a commit SHA — globally unique as a content address, but the SAME commit legitimately lives in many repos (a fork and its upstream), so a bare SHA would drop one repo's hit for every shared commit.
Repo ULIDs and real session ids are globally unique, so they pass through. Mirrors of the SAME repo still carry the same org/repo and collapse correctly. ResultID stays the raw, machine-lookup id for display.
func (*Result) MarshalJSON ¶ added in v0.7.6
MarshalJSON implements custom JSON marshaling to produce the API wire format.
func (*Result) ResultAuthor ¶ added in v0.7.6
ResultAuthor returns the display author for any result type. PR raw payloads carry the author login under "userLogin" (searcher.PRResult).
func (*Result) ResultBranch ¶ added in v0.7.6
ResultBranch returns the branch for any result type. PR raw payloads carry the head branch under "headBranch" (searcher.PRResult).
func (*Result) ResultCheckpointCount ¶ added in v0.10.0
ResultCheckpointCount returns the indexed checkpoint count for raw-payload repo rows (searcher.RepoResult), 0 elsewhere.
func (*Result) ResultCreatedAt ¶ added in v0.7.6
ResultCreatedAt returns the createdAt for any result type.
func (*Result) ResultID ¶ added in v0.7.6
ResultID returns the primary ID for any result type. Types without a typed struct (repo, pr) fall back to the "id" field of the raw payload; for a repo row that is the placement ULID query-serve keys the namespace on (ENT-1912, entire-search#198), the same identifier the repo index and the `repo` filter use.
func (*Result) ResultOrg ¶ added in v0.7.6
ResultOrg returns the org for any result type. Repo/PR raw payloads may only carry an owner-qualified "fullName"; its owner segment is the org.
func (*Result) ResultRepo ¶ added in v0.7.6
ResultRepo returns the bare repo name (no owner) for any result type, so callers can join it with ResultOrg without doubling the owner. Repo/PR raw payloads carry it under "repo" or "name", or qualified inside "fullName".
func (*Result) ResultTitle ¶ added in v0.7.6
ResultTitle returns the primary display text for any result type. Repo/PR raw payloads identify themselves via "title", "name", or "fullName".
func (*Result) UnmarshalJSON ¶ added in v0.7.6
UnmarshalJSON implements custom JSON unmarshaling to parse typed data.
type SessionResult ¶ added in v0.7.6
type SessionResult struct {
SessionID string `json:"sessionId"`
// MatchedCheckpointID is the carrier checkpoint the search service anchors a
// session row to — present on every session row. For a server-folded legacy
// session (ENT-1595) the sessionId is empty and this IS the row's identity
// (the checkpoint predates the sessionId attribute), so ResultID and the
// cross-cell dedupe (DedupID) fall back to it, repo-qualified, and a mirrored
// repo reports the row once instead of twice. Drill-down is
// `entire checkpoint explain <id>`, not `entire session info`.
MatchedCheckpointID string `json:"matchedCheckpointId,omitempty"`
DisplayName string `json:"displayName"`
Prompt *string `json:"prompt"`
Agent *string `json:"agent"`
Model *string `json:"model"`
StepCount int `json:"stepCount"`
Org string `json:"org"`
Repo string `json:"repo"`
Branch *string `json:"branch"`
AuthorUsername *string `json:"authorUsername"`
CreatedAt string `json:"createdAt"`
}
SessionResult represents a session returned by the search service.
type Timing ¶ added in v0.7.6
type Timing struct {
TotalMs *float64 `json:"total_ms"`
KeywordMs *float64 `json:"keyword_ms"`
EmbeddingMs *float64 `json:"embedding_ms"`
VectorMs *float64 `json:"vector_ms"`
RerankMs *float64 `json:"rerank_ms"`
FanoutMs *float64 `json:"fanout_ms"`
SessionHydrationMs *float64 `json:"session_hydration_ms"`
}
Timing holds search performance timing data.