Documentation
¶
Overview ¶
Package export streams search results as JSON, CSV, or NDJSON (v0.1.0, owner directive §4).
Contracts:
- Same semantics: export pages through the SAME SearchService the interactive surfaces use — the keyset cursor guarantees a stable page sequence even while the index changes underneath (already- emitted rows never repeat).
- Streaming: rows are written per page; memory stays O(page), not O(result set). Large exports are bounded only by MaxRows=0 (unlimited, the operator's explicit choice).
- Correct escaping: CSV is RFC 4180 via encoding/csv (quotes, commas, newlines, UTF-8); JSON/NDJSON via encoding/json.
- Honest metadata: the footer carries the compiled query info (mode, branch, took), the total count, and the index freshness notice — never credentials, never connection strings.
- Array fields (technologies, sources) serialize as ";"-joined strings inside CSV cells; JSON/NDJSON keep real arrays.
Index ¶
Constants ¶
const ( FormatJSON = "json" FormatCSV = "csv" FormatNDJSON = "ndjson" )
Format names.
const DefaultMaxRows = 10000
DefaultMaxRows is the CLI-side guard: an export without --max stops after this many rows with an explicit "raise --max" message. A Request MaxRows of 0 means unlimited.
Variables ¶
var Formats = []string{FormatJSON, FormatCSV, FormatNDJSON}
Formats lists the supported export formats.
Functions ¶
func FormatExtension ¶
FormatExtension returns the canonical file extension for a format.
func ResolveOutPath ¶
ResolveOutPath returns the output path: the explicit value (validated) or a timestamped default with the format's extension. existingOK suppresses the overwrite refusal (used by --force).
func ValidateOutPath ¶
ValidateOutPath checks an explicit --out value.
Types ¶
type Request ¶
type Request struct {
Query search.Query // GQL/mode/sort/fields/timeout; Limit is managed by the pager
Format string
// MaxRows caps the stream; 0 = unlimited.
MaxRows int
}
Request is one export job.
type Stats ¶
type Stats struct {
Rows int64 `json:"rows"`
Pages int `json:"pages"`
Format string `json:"format"`
TookMs int64 `json:"took_ms"`
Query string `json:"query"`
Mode string `json:"mode"`
Truncated bool `json:"truncated"` // stopped at MaxRows
Notice string `json:"notice,omitempty"`
}
Stats reports what one export wrote.