feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
package core
|
|
|
|
|
|
|
|
|
|
// ResultType is the SERP block type for a search result.
|
|
|
|
|
type ResultType string
|
|
|
|
|
|
|
|
|
|
const (
|
2026-04-26 02:40:08 +03:00
|
|
|
ResultTypeOrganic ResultType = "organic"
|
|
|
|
|
ResultTypeAd ResultType = "ad"
|
feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
ResultTypeFeaturedSnippet ResultType = "featured_snippet"
|
2026-04-26 02:40:08 +03:00
|
|
|
ResultTypeKnowledgePanel ResultType = "knowledge_panel"
|
|
|
|
|
ResultTypePeopleAlsoAsk ResultType = "people_also_ask"
|
|
|
|
|
ResultTypeVideo ResultType = "video"
|
|
|
|
|
ResultTypeImage ResultType = "image"
|
|
|
|
|
ResultTypeNews ResultType = "news"
|
|
|
|
|
ResultTypeShopping ResultType = "shopping"
|
|
|
|
|
ResultTypeLocal ResultType = "local"
|
|
|
|
|
ResultTypeAnswerBox ResultType = "answer_box"
|
feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Position describes where a result sits in the overall result stream.
|
|
|
|
|
type Position struct {
|
2026-05-13 01:30:54 +03:00
|
|
|
// Absolute is the 1-based rank counting from the first result of the first page,
|
|
|
|
|
// across both organic and ad blocks. Always emitted so SEO callers can plot
|
|
|
|
|
// rank vs. on-page position without inferring it from the result order.
|
feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
Absolute int `json:"absolute"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DomainInfo carries TLD-derived category signals for a result domain.
|
|
|
|
|
type DomainInfo struct {
|
2026-05-13 01:30:54 +03:00
|
|
|
TLD string `json:"tld,omitempty"`
|
|
|
|
|
SLD string `json:"sld,omitempty"`
|
|
|
|
|
// Category is one of "gov", "edu", "mil", "news", "forum", "marketplace",
|
|
|
|
|
// "social", or "" when the domain does not match any known category.
|
|
|
|
|
Category string `json:"category"`
|
feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Classification holds URL-path heuristic hints for downstream consumers.
|
|
|
|
|
type Classification struct {
|
2026-05-13 01:30:54 +03:00
|
|
|
ContentType string `json:"content_type,omitempty"`
|
|
|
|
|
SourceHint string `json:"source_hint,omitempty"`
|
feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
}
|
|
|
|
|
|
2026-05-13 01:30:54 +03:00
|
|
|
// Result is the v2 normalized result returned in search responses. Optional
|
|
|
|
|
// fields (Position, DomainInfo, Classification) are omitted when empty.
|
feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
type Result struct {
|
2026-04-26 02:40:08 +03:00
|
|
|
ID string `json:"id"`
|
|
|
|
|
Rank int `json:"rank"`
|
|
|
|
|
Type ResultType `json:"type"`
|
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
URL string `json:"url"`
|
|
|
|
|
DisplayURL string `json:"display_url"`
|
|
|
|
|
Snippet string `json:"snippet"`
|
|
|
|
|
Domain string `json:"domain"`
|
|
|
|
|
Favicon string `json:"favicon"`
|
2026-05-13 01:30:54 +03:00
|
|
|
Position *Position `json:"position,omitempty"`
|
2026-04-26 02:40:08 +03:00
|
|
|
Engine string `json:"engine"`
|
|
|
|
|
DomainInfo *DomainInfo `json:"domain_info,omitempty"`
|
feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
Classification *Classification `json:"classification,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ImageData holds image-specific URL and dimension fields.
|
|
|
|
|
type ImageData struct {
|
|
|
|
|
URL string `json:"url"`
|
|
|
|
|
Thumbnail string `json:"thumbnail,omitempty"`
|
|
|
|
|
Width int `json:"width,omitempty"`
|
|
|
|
|
Height int `json:"height,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ImageSource holds page-level context for an image result.
|
|
|
|
|
type ImageSource struct {
|
|
|
|
|
PageURL string `json:"page_url"`
|
|
|
|
|
Domain string `json:"domain"`
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-13 01:30:54 +03:00
|
|
|
// ImageResult is the v2 shape for image search results.
|
feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
type ImageResult struct {
|
2026-04-26 02:40:08 +03:00
|
|
|
ID string `json:"id"`
|
|
|
|
|
Rank int `json:"rank"`
|
|
|
|
|
Type ResultType `json:"type"`
|
|
|
|
|
Title string `json:"title"`
|
|
|
|
|
Image ImageData `json:"image"`
|
|
|
|
|
Source ImageSource `json:"source"`
|
|
|
|
|
Engine string `json:"engine"`
|
feat: v1 response envelope, normalized Result struct, clusters, and enrichment
- All search endpoints now return a JSON envelope with query echo,
meta (request_id, took_ms, engines_responded, engines_failed, version),
results array, and pagination fields
- SearchResult renamed to RawResult internally; new Result struct adds
id, type, display_url, domain, favicon, is_ad, position, engine_meta,
domain_info, classification
- Result IDs are stable SHA-256 hashes of engine+normalized_url
- Bing redirect URLs (bing.com/ck/a) are unwrapped before hashing
- ResultType enum defined: organic, ad, answer_box, featured_snippet, etc.
- /mega/search response includes clusters array grouping same-URL results
across engines with score, best_rank, and occurrences
- engines_failed field surfaces partial failures in megasearch
- Lightweight domain enrichment: TLD/SLD, is_gov/edu/mil/news/forum/
marketplace/social flags, content_type and source_hint classification
- SearchAllParallel/SearchAllImageParallel now return (results, responded, failed)
- Image endpoints return ImageEnvelope with dedicated ImageResult shape
2026-04-24 05:21:11 +03:00
|
|
|
}
|